当前位置: 首页>>代码示例>>C#>>正文


C# Impl.SolrConnection类代码示例

本文整理汇总了C#中SolrNet.Impl.SolrConnection的典型用法代码示例。如果您正苦于以下问题:C# SolrConnection类的具体用法?C# SolrConnection怎么用?C# SolrConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SolrConnection类属于SolrNet.Impl命名空间,在下文中一共展示了SolrConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupSolr

        private static void SetupSolr() {
            var connection = new SolrConnection(_httpSolrTest);
            Startup.InitContainer();

            Startup.Container.Remove<IReadOnlyMappingManager>();

            var mapper = new MappingManager();
            Mappings(mapper);
            Startup.Container.Register<IReadOnlyMappingManager>(c => mapper);

            Startup.Container.Remove<ISolrDocumentPropertyVisitor>();
            var propertyVisitor = new DefaultDocumentVisitor(mapper, Startup.Container.GetInstance<ISolrFieldParser>());
            Startup.Container.Register<ISolrDocumentPropertyVisitor>(c => propertyVisitor);

            Startup.Init<Child>(connection);
            Startup.Init<Parent>(connection);
            Startup.Init<Dictionary<string,object>>(connection);
            Startup.Container.RemoveAll<ISolrDocumentResponseParser<Dictionary<string, object>>>();
            Startup.Container.Register<ISolrDocumentResponseParser<Dictionary<string, object>>>(c => new SolrDictionaryDocumentResponseParser(c.GetInstance<ISolrFieldParser>()));

            var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Child>>();

            solr.Delete(SolrQuery.All);
            solr.Commit();
        }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:25,代码来源:IntegrationTests2.cs

示例2: Main

 static void Main(string[] args)
 {
     var builder = Startup.GetQueryBuilder();
     var conn = new SolrConnection("http://localhost:9090/solr");
     var query = builder.GetQuery(conn, new SolrQuery("*:*"), new QueryOptions {Rows = 99});
     Console.WriteLine(query);
     Console.ReadLine();
 }
开发者ID:Jroland,项目名称:SolrNet,代码行数:8,代码来源:Program.cs

示例3: ActualConnection

		public void ActualConnection() {
            var conn = new SolrConnection(solrURL) { HttpWebRequestFactory = new HttpWebRequestFactory() };
			var p = new Dictionary<string, string>();
			p["version"] = "2.1";
			p["indent"] = "on";
			p["q"] = "+video +price:[* TO 400]";
			Console.WriteLine(conn.Get("/select/", p));
		}
开发者ID:FilipVV,项目名称:SolrNet,代码行数:8,代码来源:SolrConnectionTests.cs

示例4: ActualInvalidFieldException

 public void ActualInvalidFieldException()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory());
     var p = new Dictionary<string, string>();
     p["version"] = "2.1";
     p["indent"] = "on";
     p["q"] = "idq:123";
     Console.WriteLine(conn.Get("/select/", p));
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:9,代码来源:SolrConnectionTests.cs

示例5: Cache

 public void Cache()
 {
     var conn = new SolrConnection(solrURL);
     conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
     conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
 }
开发者ID:jokin,项目名称:SolrNet,代码行数:10,代码来源:SolrConnectionTests.cs

示例6: Cache

 public void Cache()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory());
     var response1 = conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
     var response2 = conn.Get("/select/", new Dictionary<string, string> {
         {"q", "*:*"},
     });
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:10,代码来源:SolrConnectionTests.cs

示例7: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var solrServerUrl = ConfigurationManager.AppSettings["SolrServerUrl"];
            var solrConnection = new SolrConnection(solrServerUrl);
            Startup.Init<SearchResultItem>(solrConnection);
        }
开发者ID:jstrassburg,项目名称:SolrSearchEngineDemo,代码行数:13,代码来源:Global.asax.cs

示例8: ActualConnectionWithException

		public void ActualConnectionWithException() {
            var conn = new SolrConnection(solrURL);
			var p = new Dictionary<string, string>();
			p["version"] = "2.1";
			p["indent"] = "on";
			p["q"] = "idq:123";
            try {
                conn.Get("/select/", p);
                Assert.Fail("Should have thrown");
            } catch (SolrConnectionException e) {
                Console.WriteLine(e);
                Console.WriteLine(e.Url);
            }
		}
开发者ID:FilipVV,项目名称:SolrNet,代码行数:14,代码来源:SolrConnectionTests.cs

示例9: Application_Start

        protected void Application_Start() {
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Server.MapPath("/"), "log4net.config")));

            RegisterRoutes(RouteTable.Routes);

            var connection = new SolrConnection(solrURL);
            var loggingConnection = new LoggingConnection(connection);
            Startup.Init<Product>(loggingConnection);

            RegisterAllControllers();
            ControllerBuilder.Current.SetControllerFactory(new ServiceProviderControllerFactory(Startup.Container));
            ModelBinders.Binders[typeof (SearchParameters)] = new SearchParametersBinder();
            AddInitialDocuments();
        }
开发者ID:simendancer,项目名称:SolrNet,代码行数:14,代码来源:Global.asax.cs

示例10: Get

		public void Get() {
		    var response = new Mocks.HttpWebResponse {
		        dispose = () => {},
                headers = () => new WebHeaderCollection(),
                getResponseStream = () => new MemoryStream(Encoding.UTF8.GetBytes("hello world")),
		    };
		    var request = new Mocks.HttpWebRequest {
		        getResponse = () => response
		    };
		    var reqFactory = new Mocks.HttpWebRequestFactory {
		        create = _ => request
		    };
            var conn = new SolrConnection("https://pepe") {
                HttpWebRequestFactory = reqFactory,
            };
		    var r = conn.Get("", new Dictionary<string, string>());
            Assert.AreEqual("hello world", r);
		}
开发者ID:FilipVV,项目名称:SolrNet,代码行数:18,代码来源:SolrConnectionTests.cs

示例11: Post

 public void Post()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     var response = mocks.DynamicMock<IHttpWebResponse>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(request.GetRequestStream())
             .Repeat.Once()
             .Return(new MemoryStream());
         Expect.Call(reqFactory.Create(new Uri("https://pepe")))
             .Repeat.Once()
             .Return(request);
         request.Method = HttpWebRequestMethod.POST;
         LastCall.On(request).Repeat.Once();
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Return(response);
         Expect.Call(response.Headers)
             .Repeat.Any()
             .Return(new WebHeaderCollection());
         Expect.Call(response.GetResponseStream())
             .Repeat.Once()
             .Return(new MemoryStream());
     }).Verify(delegate {
         var conn = new SolrConnection("https://pepe", reqFactory);
         conn.Post("", "");
     });
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:29,代码来源:SolrConnectionTests.cs

示例12: NoCache_performance

 public void NoCache_performance()
 {
     var conn = new SolrConnection(solrURL, new HttpWebRequestFactory()) {
         Cache = new NullCache(),
     };
     TestCache(conn);
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:7,代码来源:SolrConnectionTests.cs

示例13: InvalidHostPost_ShouldThrowException

 public void InvalidHostPost_ShouldThrowException()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(request.GetRequestStream())
             .Repeat.Once()
             .Throw(new WebException());
         Expect.Call(reqFactory.Create(new Uri("http://lalala:12345/update")))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
     }).Verify(delegate {
         var conn = new SolrConnection("http://lalala:12345", reqFactory);
         conn.Post("/update", "");
     });
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:18,代码来源:SolrConnectionTests.cs

示例14: InvalidHostGet_ShouldThrowException

 public void InvalidHostGet_ShouldThrowException()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(reqFactory.Create(new UriBuilder().Uri))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Throw(new WebException());
     }).Verify(delegate {
         var conn = new SolrConnection("http://lalala:12345", reqFactory);
         conn.Get("", new Dictionary<string, string>());
     });
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:18,代码来源:SolrConnectionTests.cs

示例15: GetWithNullParameters_ShouldAcceptNull

 public void GetWithNullParameters_ShouldAcceptNull()
 {
     var mocks = new MockRepository();
     var reqFactory = mocks.StrictMock<IHttpWebRequestFactory>();
     var request = mocks.DynamicMock<IHttpWebRequest>();
     var response = mocks.DynamicMock<IHttpWebResponse>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(reqFactory.Create(new UriBuilder().Uri))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(request);
         Expect.Call(response.Headers)
             .Repeat.Any()
             .Return(new WebHeaderCollection());
         Expect.Call(request.GetResponse())
             .Repeat.Once()
             .Return(response);
         Expect.Call(response.GetResponseStream())
             .Repeat.Once()
             .Return(new MemoryStream());
     }).Verify(delegate {
         var conn = new SolrConnection("https://pepe", reqFactory);
         conn.Get("", new Dictionary<string, string>());
     });
 }
开发者ID:rupertbates,项目名称:SolrNet,代码行数:25,代码来源:SolrConnectionTests.cs


注:本文中的SolrNet.Impl.SolrConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。