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


C# SolrQueryExecuter.Execute方法代码示例

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


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

示例1: Execute

 public void Execute()
 {
     const string queryString = "id:123456";
     var q = new Dictionary<string, string>();
     q["q"] = queryString;
     var conn = new MockConnection(q);
     var mocks = new MockRepository();
     var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
     var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
     var serializer = mocks.StrictMock<ISolrQuerySerializer>();
     With.Mocks(mocks).Expecting(() => {
         Expect.On(parser)
             .Call(parser.Parse(null))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(mockR);
         Expect.On(serializer)
             .Call(serializer.Serialize(null))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(queryString);
     }).Verify(() => {
         var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, null, null);
         var r = queryExecuter.Execute(new SolrQuery(queryString), null);
     });
 }
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:26,代码来源:SolrQueryExecuterTests.cs

示例2: Execute

        public void Execute() {
            const string queryString = "id:123456";
            var q = new Dictionary<string, string>();
            q["q"] = queryString;
            var conn = new MockConnection(q);
            var serializer = new MSolrQuerySerializer();
            serializer.serialize += _ => queryString;
            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();

            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, null, null);
            var r = queryExecuter.Execute(new SolrQuery(queryString), null);
            Assert.AreEqual(1, serializer.serialize.Calls);
        }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:14,代码来源:SolrQueryExecuterTests.cs

示例3: Sort

 public void Sort() {
     const string queryString = "id:123456";
     var q = new Dictionary<string, string>();
     q["q"] = queryString;
     q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
     q["sort"] = "id asc";
     var conn = new MockConnection(q);
     var querySerializer = new SolrQuerySerializerStub(queryString);
     var parser = new MSolrAbstractResponseParser<TestDocument>();
     parser.parse &= x => x.Expect(1);
     var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
     var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
         OrderBy = new[] { new SortOrder("id") }
     });
     parser.parse.Verify();
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:16,代码来源:SolrQueryExecuterTests.cs

示例4: tt

 public void tt()
 {
     var mocks = new MockRepository();
     var connection = mocks.StrictMock<ISolrConnection>();
     var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(connection.Get(null, null))
             .IgnoreArguments()
             .Repeat.Once()
             .Return("");
         Expect.Call(parser.Parse(null))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(new SolrQueryResults<TestDocument>());
     }).Verify(delegate {
         var q = new SolrQueryExecuter<TestDocument>(parser, connection, null, null);
         var r = q.Execute(new SolrQuery("id:123456"), null);
     });
 }
开发者ID:7digital,项目名称:SolrNet,代码行数:19,代码来源:SolrQueryTests.cs

示例5: ResultFields

        public void ResultFields()
        {
            const string queryString = "id:123456";
            var q = new Dictionary<string, string>();
            q["q"] = queryString;
            q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
            q["fl"] = "id,name";
            var conn = new MockConnection(q);
            var querySerializer = new SolrQuerySerializerStub(queryString);

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
            var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
                Fields = new[] { "id", "name" },
            });
        }
开发者ID:pampero,项目名称:cgFramework,代码行数:17,代码来源:SolrQueryExecuterTests.cs

示例6: MultipleFacetFields

        public void MultipleFacetFields()
        {
            var conn = new MockConnection(new[] {
                KV.Create("q", ""),
                KV.Create("rows", SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString()),
                KV.Create("facet", "true"),
                KV.Create("facet.field", "Id"),
                KV.Create("facet.field", "OtherField"),
            });
            var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
            var facetQuerySerializer = new DefaultFacetQuerySerializer(serializer, new DefaultFieldSerializer());

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, facetQuerySerializer, null);
            queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
                Facet = new FacetParameters {
                    Queries = new ISolrFacetQuery[] {
                        new SolrFacetFieldQuery("Id"),
                        new SolrFacetFieldQuery("OtherField"),
                    }
                }
            });
        }
开发者ID:pampero,项目名称:cgFramework,代码行数:24,代码来源:SolrQueryExecuterTests.cs

示例7: Highlighting

        public void Highlighting()
        {
            const string highlightedField = "field1";
            const string afterTerm = "after";
            const string beforeTerm = "before";
            const int snippets = 3;
            const string alt = "alt";
            const int fragsize = 7;
            var q = new Dictionary<string, string>();
            q["q"] = "";
            q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
            q["hl"] = "true";
            q["hl.fl"] = highlightedField;
            q["hl.snippets"] = snippets.ToString();
            q["hl.fragsize"] = fragsize.ToString();
            q["hl.requireFieldMatch"] = "true";
            q["hl.alternateField"] = alt;
            q["hl.tag.pre"] = beforeTerm;
            q["hl.tag.post"] = afterTerm;
            q["hl.regex.slop"] = "4.12";
            q["hl.regex.pattern"] = "\\.";
            q["hl.regex.maxAnalyzedChars"] = "8000";
            q["hl.usePhraseHighlighter"] = "true";
            q["hl.useFastVectorHighlighter"] = "true";
            q["hl.highlightMultiTerm"] = "true";
            q["hl.mergeContiguous"] = "true";
            q["hl.maxAnalyzedChars"] = "12";
            q["hl.maxAlternateFieldLength"] = "22";
            q["hl.fragmenter"] = "regex";

            var conn = new MockConnection(q);
            var querySerializer = new SolrQuerySerializerStub("");

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
            queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
                Highlight = new HighlightingParameters {
                    Fields = new[] { highlightedField },
                    AfterTerm = afterTerm,
                    BeforeTerm = beforeTerm,
                    Snippets = snippets,
                    AlternateField = alt,
                    Fragsize = fragsize,
                    RequireFieldMatch = true,
                    RegexSlop = 4.12,
                    RegexPattern = "\\.",
                    RegexMaxAnalyzedChars = 8000,
                    UsePhraseHighlighter = true,
                    UseFastVectorHighlighter = true,
                    MergeContiguous = true,
                    MaxAnalyzedChars = 12,
                    HighlightMultiTerm = true,
                    MaxAlternateFieldLength = 22,
                    Fragmenter = SolrHighlightFragmenter.Regex
                }
            });
        }
开发者ID:pampero,项目名称:cgFramework,代码行数:58,代码来源:SolrQueryExecuterTests.cs

示例8: FilterQuery

        public void FilterQuery()
        {
            var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
            var conn = new MockConnection(new[] {
                KV.Create("q", "*:*"),
                KV.Create("rows", "10"),
                KV.Create("fq", "id:0"),
                KV.Create("fq", "id:2"),
            });

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null) {
                DefaultRows = 10,
            };
            queryExecuter.Execute(SolrQuery.All, new QueryOptions {
                FilterQueries = new[] {
                    new SolrQuery("id:0"),
                    new SolrQuery("id:2"),
                },
            });
        }
开发者ID:pampero,项目名称:cgFramework,代码行数:22,代码来源:SolrQueryExecuterTests.cs

示例9: Facets

        public void Facets()
        {
            var q = new Dictionary<string, string>();
            q["q"] = "";
            q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
            q["facet"] = "true";
            q["facet.field"] = "Id";
            q["facet.query"] = "id:[1 TO 5]";
            var conn = new MockConnection(q);
            var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, facetQuerySerializer, null);
            queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
                Facet = new FacetParameters {
                    Queries = new ISolrFacetQuery[] {
                        new SolrFacetFieldQuery("Id"),
                        new SolrFacetQuery(new SolrQuery("id:[1 TO 5]")),
                    }
                }
            });
        }
开发者ID:pampero,项目名称:cgFramework,代码行数:24,代码来源:SolrQueryExecuterTests.cs

示例10: HighlightingWithoutFieldsOutputsPrePost

        public void HighlightingWithoutFieldsOutputsPrePost() {
            const string afterTerm = "after";
            const string beforeTerm = "before";

            var q = new Dictionary<string, string>();
            q["q"] = "";
            q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
            q["hl"] = "true";
            q["hl.tag.pre"] = beforeTerm;
            q["hl.tag.post"] = afterTerm;
            q["hl.useFastVectorHighlighter"] = "true";

            var conn = new MockConnection(q);
            var querySerializer = new SolrQuerySerializerStub("");

            var parser = new MSolrAbstractResponseParser<TestDocument>();
            parser.parse &= x => x.Stub();
            var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
            queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
                Highlight = new HighlightingParameters {
                    AfterTerm = afterTerm,
                    BeforeTerm = beforeTerm,
                    UseFastVectorHighlighter = true,
                }
            });
        }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:26,代码来源:SolrQueryExecuterTests.cs

示例11: SortMultipleWithOrders

 public void SortMultipleWithOrders()
 {
     const string queryString = "id:123456";
     var q = new Dictionary<string, string>();
     q["q"] = queryString;
     q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
     q["sort"] = "id asc,name desc";
     var conn = new MockConnection(q);
     var mocks = new MockRepository();
     var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
     var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
     var querySerializer = new SolrQuerySerializerStub(queryString);
     With.Mocks(mocks).Expecting(() => {
         Expect.Call(parser.Parse(null)).IgnoreArguments().Repeat.Once().Return(mockR);
     }).Verify(() => {
         var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
         var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
             OrderBy = new[] {
                 new SortOrder("id", Order.ASC),
                 new SortOrder("name", Order.DESC)
             }
         });
     });
 }
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:24,代码来源:SolrQueryExecuterTests.cs

示例12: ResultFields

 public void ResultFields()
 {
     const string queryString = "id:123456";
     var q = new Dictionary<string, string>();
     q["q"] = queryString;
     q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
     q["fl"] = "id,name";
     var conn = new MockConnection(q);
     var mocks = new MockRepository();
     var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
     var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
     var querySerializer = new SolrQuerySerializerStub(queryString);
     With.Mocks(mocks).Expecting(delegate {
         Expect.Call(parser.Parse(null)).IgnoreArguments().Repeat.Once().Return(mockR);
     }).Verify(() => {
         var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
         var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
             Fields = new[] {"id", "name"},
         });
     });
 }
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:21,代码来源:SolrQueryExecuterTests.cs

示例13: FilterQuery

 public void FilterQuery()
 {
     var mocks = new MockRepository();
     var parser = mocks.DynamicMock<ISolrQueryResultParser<TestDocument>>();
     var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var conn = new MockConnection(new[] {
         KV.Create("q", "*:*"),
         KV.Create("rows", "10"),
         KV.Create("fq", "id:0"),
         KV.Create("fq", "id:2"),
     });
     var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null) {
         DefaultRows = 10,
     };
     queryExecuter.Execute(SolrQuery.All, new QueryOptions {
         FilterQueries = new[] {
             new SolrQuery("id:0"),
             new SolrQuery("id:2"),
         },
     });
 }
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:21,代码来源:SolrQueryExecuterTests.cs


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