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


C# SolrBasicServer.AsQueryable方法代码示例

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


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

示例1: Collection

        public void Collection()
        {
            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);

            var linqQuery = from doc in solr.AsQueryable()
                            where doc.Categories.AnyItem() == "cat1"
                            select doc;

            QueryOptions qo;
            var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);

            Assert.AreEqual("(cat:cat1)", resDocs.Query);
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:21,代码来源:QueryableSolrNetTester.cs

示例2: Boosting

        public void Boosting()
        {
            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);

            var linqQuery = from doc in solr.AsQueryable()
                            where (doc.Name == "john").Boost(10)
                            select doc;

            QueryOptions qo;
            var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);

            Assert.AreEqual("(name:john)^10", resDocs.Query);
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:21,代码来源:QueryableSolrNetTester.cs

示例3: AndsOrs

        public void AndsOrs()
        {
            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);

            var linqQuery = from doc in solr.AsQueryable()
                            where doc.DefaultFieldEquals("aa") && (doc.Price >= 1 || doc.Price <= 11)
                            select doc;

            QueryOptions qo;
            var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);

            Assert.AreEqual("(aa AND ((price:[1 TO *]) OR (price:[* TO  11])))", resDocs.Query);
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:21,代码来源:QueryableSolrNetTester.cs

示例4: Sort

        public void Sort()
        {
            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);
            int priceVal = 1;
            DateTime dt = new DateTime(2011, 1, 1);
            var linqQuery = from doc in solr.AsQueryable()
                            where (doc.Price >= priceVal || doc.Timestamp >= dt)
                            orderby doc.Id, doc.Price descending
                            select doc;

            QueryOptions qo;
            var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);

            Assert.AreEqual(qo.OrderBy.Count, 2);
            var so = new SortOrder("id", Order.ASC);
            Assert.IsTrue(qo.OrderBy.Contains(so));
            so = new SortOrder("price", Order.DESC);
            Assert.IsTrue(qo.OrderBy.Contains(so));
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:27,代码来源:QueryableSolrNetTester.cs

示例5: PartialEval

        public void PartialEval()
        {
            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);
            int priceVal = 1;
            DateTime dt = new DateTime(2011, 1, 1);
            var linqQuery = from doc in solr.AsQueryable()
                            where (doc.Price >= priceVal || doc.Timestamp >= dt)
                            select doc;

            QueryOptions qo;
            var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);

            Assert.AreEqual("((price:[1 TO *]) OR (timestamp:[2011-01-01T12:00:00.000Z TO *]))", resDocs.Query);
        }
开发者ID:Cort01,项目名称:SolrNet,代码行数:22,代码来源:QueryableSolrNetTester.cs


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