public void SetConnectionTimeoutInMulticore() { const string core0url = "http://localhost:8983/solr/core0"; const string core1url = "http://localhost:8983/solr/core1"; var solrFacility = new SolrNetFacility("http://localhost:8983/solr/defaultCore"); solrFacility.AddCore("core0-id", typeof(Document), core0url); solrFacility.AddCore("core1-id", typeof(Document), core1url); solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url); var container = new WindsorContainer(); container.Kernel.ComponentModelCreated += model => { if (model.Implementation == typeof(SolrConnection)) { model.Parameters.Add("Timeout", "2000"); } }; container.AddFacility("solr", solrFacility); var allTimeouts = container.ResolveAll <ISolrConnection>().Cast <SolrConnection>().Select(x => x.Timeout); foreach (var t in allTimeouts) { Assert.AreEqual(2000, t); } }
public void AddCore() { const string core0url = "http://localhost:8983/solr/core0"; const string core1url = "http://localhost:8983/solr/core1"; var solrFacility = new SolrNetFacility("http://localhost:8983/solr/defaultCore"); solrFacility.AddCore("core0-id", typeof(Document), core0url); solrFacility.AddCore("core1-id", typeof(Document), core1url); solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url); var container = new WindsorContainer(); container.AddFacility("solr", solrFacility); TestCores(container); }
public void AddCoreWithPostConnections() { const string core0url = "http://localhost:8983/solr/techproducts/core0"; const string core1url = "http://localhost:8983/solr/techproducts/core1"; var solrFacility = new SolrNetFacility("http://localhost:8983/solr/techproducts/defaultCore"); solrFacility.AddCore("core0-id", typeof(Document), core0url, true); solrFacility.AddCore("core1-id", typeof(Document), core1url, true); solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url, true); var container = new WindsorContainer(); container.AddFacility(solrFacility); TestCoresWithPostConnections(container); }
public SolrMachine(string coreName) { var url = string.Format("http://xxx/solr/{0}", coreName); myContainer.Register(Component.For <IHttpWebRequestFactory>().ImplementedBy <SolrAuth>()); var solrFacility = new SolrNetFacility(string.Format("http://xxx/solr/{0}", "defaultCollection")); solrFacility.AddCore(coreName, typeof(T), url); myContainer.AddFacility(solrFacility); this.actuallyInstance = myContainer.Resolve <ISolrOperations <T> >(); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); DependencyConfig.Configure(new ContainerBuilder()); AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier; Database.SetInitializer(new MigrateDatabaseToLatestVersion <MetadataContext, Migrations.Configuration>()); MvcHandler.DisableMvcResponseHeader = true; // setting locale var culture = new CultureInfo("nb-NO"); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; log4net.Config.XmlConfigurator.Configure(); //https://github.com/mausch/SolrNet/blob/master/Documentation/Multi-core-instance.md var solrFacility = new SolrNetFacility(WebConfigurationManager.AppSettings["SolrServerUrl"]); solrFacility.AddCore(SolrCores.Metadata, typeof(MetadataIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/metadata"); solrFacility.AddCore(SolrCores.MetadataEnglish, typeof(MetadataIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/metadata_en"); solrFacility.AddCore(SolrCores.MetadataAll, typeof(MetadataIndexAllDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/metadata_all"); solrFacility.AddCore(SolrCores.MetadataAllEnglish, typeof(MetadataIndexAllDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/metadata_all_en"); solrFacility.AddCore(SolrCores.Services, typeof(ServiceIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/services"); solrFacility.AddCore(SolrCores.ServicesEnglish, typeof(ServiceIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/services_en"); solrFacility.AddCore(SolrCores.Applications, typeof(ApplicationIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/applications"); solrFacility.AddCore(SolrCores.ApplicationsEnglish, typeof(ApplicationIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/applications_en"); solrFacility.AddCore(SolrCores.Articles, typeof(ArticleIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/articles"); solrFacility.AddCore(SolrCores.ArticlesEnglish, typeof(ArticleIndexDoc), WebConfigurationManager.AppSettings["SolrServerUrl"] + "/solr/articles_en"); indexContainer.AddFacility(solrFacility); }
public void SetConnectionTimeoutInMulticore() { const string core0url = "http://localhost:8983/solr/core0"; const string core1url = "http://localhost:8983/solr/core1"; var solrFacility = new SolrNetFacility("http://localhost:8983/solr/defaultCore"); solrFacility.AddCore("core0-id", typeof(Document), core0url); solrFacility.AddCore("core1-id", typeof(Document), core1url); solrFacility.AddCore("core2-id", typeof(Core1Entity), core1url); var container = new WindsorContainer(); container.Kernel.ComponentModelCreated += model => { if (model.Implementation == typeof(SolrConnection)) model.Parameters.Add("Timeout", "2000"); }; container.AddFacility("solr", solrFacility); var allTimeouts = container.ResolveAll<ISolrConnection>().Cast<SolrConnection>().Select(x => x.Timeout); foreach (var t in allTimeouts) Assert.AreEqual(2000, t); }
static void Main(string[] args) { //Startup.Init<Course>("http://localhost:8983/solr/MercDemo"); //ISolrOperations<Media> solr = ServiceLocator.Current.GetInstance<ISolrOperations<Media>>(); IWindsorContainer container = new WindsorContainer(); SolrNetFacility solrNetFacility = new SolrNetFacility("http://localhost:8983/solr"); solrNetFacility.AddCore("core1", typeof(Media), "http://localhost:8983/solr/Document"); solrNetFacility.AddCore("core2", typeof(Media2), "http://localhost:8983/solr/Metadata"); container.AddFacility("solr", solrNetFacility); ISolrOperations <Media> solrCore1 = container.Resolve <ISolrOperations <Media> >("core1"); ISolrOperations <Media2> solrCore2 = container.Resolve <ISolrOperations <Media2> >("core2"); Console.WriteLine("Please enter query:"); string queryFromUser = Console.ReadLine(); while (!string.IsNullOrWhiteSpace(queryFromUser)) { SolrQueryResults <Media> Medias = solrCore1.Query(queryFromUser); Console.WriteLine(); Console.WriteLine("*Results*"); Console.WriteLine("Total found: " + Medias.NumFound); int i = 0; foreach (Media media in Medias) { Console.WriteLine(i++ + ": " + media.MediaId + " "); } Console.WriteLine(); Console.Write("Execution time (ms): " + Medias.Header.QTime); SolrQueryResults <Media2> Medias2 = solrCore2.Query(queryFromUser); Console.WriteLine(); Console.WriteLine("*Results*"); Console.WriteLine("Total found: " + Medias2.NumFound); int j = 0; foreach (Media2 media2 in Medias2) { Console.WriteLine(j++ + ": " + media2.MediaId + " "); } Console.WriteLine(); Console.Write("Execution time (ms): " + Medias2.Header.QTime); //Saving Search Results Guid guid = Guid.NewGuid(); string remoteUri = "http://localhost:8983/solr/Document/select?q=" + queryFromUser + "&wt=json&indent=true"; string fileName = "SearchResults-" + guid + "-1.json", myStringWebResource = null; WebClient myWebClient = new WebClient(); myStringWebResource = remoteUri + fileName; myWebClient.DownloadFile(myStringWebResource, fileName); Console.WriteLine("\nSuccessfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource); Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t"); string remoteUri2 = "http://localhost:8983/solr/Metadata/select?q=" + queryFromUser + "&wt=json&indent=true"; string fileName2 = "SearchResults-" + guid + "-2.json", myStringWebResource2 = null; WebClient myWebClient2 = new WebClient(); myStringWebResource2 = remoteUri2 + fileName2; myWebClient2.DownloadFile(myStringWebResource2, fileName2); Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName2, myStringWebResource2); Console.ReadLine(); Console.WriteLine(Environment.NewLine + "Please enter query:"); queryFromUser = Console.ReadLine(); } Console.WriteLine(Environment.NewLine + "Demo completed!"); }