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


C# SolrBasicServer.Query方法代码示例

本文整理汇总了C#中SolrBasicServer.Query方法的典型用法代码示例。如果您正苦于以下问题:C# SolrBasicServer.Query方法的具体用法?C# SolrBasicServer.Query怎么用?C# SolrBasicServer.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SolrBasicServer的用法示例。


在下文中一共展示了SolrBasicServer.Query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FilterQueries

 public void FilterQueries()
 {
     var conn = new MockConnection(new Dictionary<string, string> {
         {"fq", "id:0"},
         {"q", "*:*"},
         {"rows", "100000000"},
     });
     var mocks = new MockRepository();
     var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
     var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
     ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
     solr.Query(SolrQuery.All, new QueryOptions {
         FilterQueries = new[] {new SolrQuery("id:0")},
     });
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:15,代码来源:FilterQueryTests.cs

示例2: QueryWithSortAndPagination

        public void QueryWithSortAndPagination()
        {
            const string qstring = "id:123";
            const int start = 10;
            const int rows = 20;

            var mocks = new MockRepository();
            var query = new Dictionary<string, string>();
            query["q"] = qstring;
            query["start"] = start.ToString();
            query["rows"] = rows.ToString();
            query["sort"] = "id asc,name desc";
            var connection = new MockConnection(query);
            var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
            var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
            var querySerializer = mocks.StrictMock<ISolrQuerySerializer>();
            With.Mocks(mocks).Expecting(() => {
                Expect.On(querySerializer)
                    .Call(querySerializer.Serialize(null))
                    .IgnoreArguments()
                    .Return(qstring);
                Expect.On(parser)
                    .Call(parser.Parse(null))
                    .IgnoreArguments()
                    .Return(new SolrQueryResults<TestDocumentWithUniqueKey>());
            }).Verify(() => {
                var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(parser, connection, querySerializer, null);
                var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer, null, null, null, null, null);
                var r = solr.Query(new SolrQuery(qstring), new QueryOptions {
                    Start = start,
                    Rows = rows,
                    OrderBy = new[] {
                        new SortOrder("id", Order.ASC),
                        new SortOrder("name", Order.DESC)
                    }
                });
            });
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:38,代码来源:SolrOperationsTests.cs

示例3: FacetQuery

 public void FacetQuery()
 {
     var mocks = new MockRepository();
     var query = new Dictionary<string, string>();
     query["q"] = "";
     query["rows"] = SolrQueryExecuter<TestDocumentWithUniqueKey>.ConstDefaultRows.ToString();
     query["facet"] = "true";
     query["facet.query"] = "id:1";
     var connection = new MockConnection(query);
     var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
     var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
     var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
     With.Mocks(mocks).Expecting(() => {
         Expect.On(parser)
             .Call(parser.Parse(null))
             .IgnoreArguments()
             .Return(new SolrQueryResults<TestDocumentWithUniqueKey>());
     }).Verify(() => {
         var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(parser, connection, querySerializer, facetQuerySerializer);
         var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer, null, null, null, null, null);
         var r = solr.Query(new SolrQuery(""), new QueryOptions {
             Facet = new FacetParameters {
                 Queries = new ISolrFacetQuery[] {
                     new SolrFacetQuery(new SolrQuery("id:1")),
                 },
             }
         });
     });
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:30,代码来源:SolrOperationsTests.cs

示例4: QueryWithPagination

        public void QueryWithPagination()
        {
            const string qstring = "id:123";
            const int start = 10;
            const int rows = 20;

            var mocks = new MockRepository();
            //var connection = mocks.CreateMock<ISolrConnection>();
            var query = new Dictionary<string, string>();
            query["q"] = qstring;
            query["start"] = start.ToString();
            query["rows"] = rows.ToString();
            var connection = new MockConnection(query);
            var parser = mocks.CreateMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
            var docSerializer = mocks.CreateMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
            With.Mocks(mocks).Expecting(() => {
                Expect.On(parser).Call(parser.Parse(null))
                    .IgnoreArguments()
                    .Return(new SolrQueryResults<TestDocumentWithUniqueKey>());
            }).Verify(() => {
                var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(connection, parser);
                var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer);
                var r = solr.Query(new SolrQuery(qstring), new QueryOptions {Start = start, Rows = rows});
            });
        }
开发者ID:osdezwart,项目名称:SolrNet,代码行数:25,代码来源:SolrOperationsTests.cs

示例5: QueryWithSortAndPagination

        public void QueryWithSortAndPagination()
        {
            const string qstring = "id:123";
            const int start = 10;
            const int rows = 20;

            var connection = new MSolrConnection();
            connection.get += (url, param) => {
                Assert.AreEqual("/select", url);
                var expectedParams = new Dictionary<string, string> {
                    {"q", qstring},
                    {"start", start.ToString()},
                    {"rows", rows.ToString()},
                    {"sort", "id asc,name desc"},
                };
                Assert.AreElementsEqualIgnoringOrder(expectedParams, param);
                return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
            };

            var querySerializer = new MSolrQuerySerializer();
            querySerializer.serialize += _ => qstring;

            var resultParser = new MSolrAbstractResponseParser<TestDocumentWithUniqueKey>();
            resultParser.parse &= x => x.Stub();

            var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(resultParser, connection, querySerializer, null, null);
            var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, null, null, null, null, null, null);
            var r = solr.Query(new SolrQuery(qstring), new QueryOptions {
                Start = start,
                Rows = rows,
                OrderBy = new[] {
                    new SortOrder("id", Order.ASC),
                    new SortOrder("name", Order.DESC)
                }
            });

            Assert.AreEqual(1, connection.get.Calls);
        }
开发者ID:rivuc,项目名称:SolrNet-1,代码行数:38,代码来源:SolrOperationsTests.cs

示例6: FacetQuery

        public void FacetQuery()
        {
            var connection = new MSolrConnection();
            connection.get += (url, param) => {
                Assert.AreEqual("/select", url);
                var expectedParams = new Dictionary<string, string> {
                    {"q", ""},
                    {"rows", SolrQueryExecuter<TestDocumentWithUniqueKey>.ConstDefaultRows.ToString()},
                    {"facet", "true"},
                    {"facet.query", "id:1"},
                };
                Assert.AreElementsEqualIgnoringOrder(expectedParams, param);
                return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
            };

            var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
            var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
            var parser = new MSolrAbstractResponseParser<TestDocumentWithUniqueKey>();
            parser.parse &= x => x.Stub();
            var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(parser, connection, querySerializer, facetQuerySerializer, null);
            var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, null, null, null, null, null, null);
            var r = solr.Query(new SolrQuery(""), new QueryOptions {
                Facet = new FacetParameters {
                    Queries = new ISolrFacetQuery[] {
                        new SolrFacetQuery(new SolrQuery("id:1")),
                    },
                }
            });

            Assert.AreEqual(1, connection.get.Calls);
        }
开发者ID:rivuc,项目名称:SolrNet-1,代码行数:31,代码来源:SolrOperationsTests.cs


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