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


C# QuerySerializers.DefaultQuerySerializer类代码示例

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


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

示例1: Boost_with_high_value

 public void Boost_with_high_value()
 {
     var q = new SolrQueryBoost(new SolrQuery("solr"), 34.2E10);
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var query = serializer.Serialize(q);
     Assert.AreEqual("(solr)^342000000000", query);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:7,代码来源:SolrQueryBoostTests.cs

示例2: SolrQuery_Boost

 public void SolrQuery_Boost()
 {
     var q = new SolrQuery("solr").Boost(12.2);
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var query = serializer.Serialize(q);
     Assert.AreEqual("(solr)^12.2", query);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:7,代码来源:SolrQueryBoostTests.cs

示例3: Query

 public void Query()
 {
     var q = new SolrHasValueQuery("name");
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var query = serializer.Serialize(q);
     Assert.AreEqual("name:[* TO *]", query);
 }
开发者ID:holytshirt,项目名称:SolrNet,代码行数:7,代码来源:SolrHasValueQueryTests.cs

示例4: 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

示例5: FacetFieldQuery

 public void FacetFieldQuery()
 {
     var mocks = new MockRepository();
     var query = new Dictionary<string, string>();
     query["q"] = "*:*";
     query["facet"] = "true";
     query["facet.field"] = "cat";
     query["rows"] = "0";
     var connection = new MockConnection(query);
     var resultParser = mocks.StrictMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
     var mapper = mocks.StrictMock<IReadOnlyMappingManager>();
     var validationManager = mocks.StrictMock<IMappingValidator>();
     var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
     With.Mocks(mocks).Expecting(() => {
         Expect.On(resultParser)
             .Call(resultParser.Parse(""))
             .IgnoreArguments()
             .Repeat.Once()
             .Return(new SolrQueryResults<TestDocumentWithUniqueKey> {
                 FacetFields = new Dictionary<string, ICollection<KeyValuePair<string, int>>> {
                     {
                         "cat", new List<KeyValuePair<string, int>> {
                             new KeyValuePair<string, int>("electronics", 5),
                             new KeyValuePair<string, int>("hard drive", 3),
                         }
                         }
                 }
             });
     }).Verify(() => {
         var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
         var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
         var queryExecuter = new SolrQueryExecuter<TestDocumentWithUniqueKey>(resultParser, connection, querySerializer, facetQuerySerializer);
         var basicSolr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, queryExecuter, docSerializer, null, null, null, null, null);
         var solr = new SolrServer<TestDocumentWithUniqueKey>(basicSolr, mapper, validationManager);
         var r = solr.FacetFieldQuery(new SolrFacetFieldQuery("cat"));
         Assert.AreEqual(2, r.Count);
         Assert.AreEqual("electronics", r.First().Key);
     });
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:39,代码来源:SolrOperationsTests.cs

示例6: Serialize

 public string Serialize(object q)
 {
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     return serializer.Serialize(q);
 }
开发者ID:holytshirt,项目名称:SolrNet,代码行数:5,代码来源:QueryBuildingTests.cs

示例7: 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

示例8: GetAllParameters_mlt_with_field_query

 public void GetAllParameters_mlt_with_field_query()
 {
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var qe = new SolrQueryExecuter<TestDocument>(null, null, serializer, null, null);
     var p = qe.GetAllMoreLikeThisHandlerParameters(
         new SolrMoreLikeThisHandlerQuery(new SolrQueryByField("id", "1234")),
         new MoreLikeThisHandlerQueryOptions(
             new MoreLikeThisHandlerParameters(new[] { "one", "three" }) {
                 MatchInclude = false,
                 MatchOffset = 5,
                 ShowTerms = InterestingTerms.None,
             }) {
                 Start = 0,
                 Rows = 5,
                 Fields = new[] { "one", "two", "three" },
             }).ToList();
     Assert.Contains(p, KV.Create("q", "id:(1234)"));
     Assert.Contains(p, KV.Create("start", "0"));
     Assert.Contains(p, KV.Create("rows", "5"));
     Assert.Contains(p, KV.Create("fl", "one,two,three"));
     Assert.Contains(p, KV.Create("mlt.fl", "one,three"));
     Assert.Contains(p, KV.Create("mlt.match.include", "false"));
     Assert.Contains(p, KV.Create("mlt.match.offset", "5"));
     Assert.Contains(p, KV.Create("mlt.interestingTerms", "none"));
 }
开发者ID:pampero,项目名称:cgFramework,代码行数:25,代码来源:SolrQueryExecuterTests.cs

示例9: 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

示例10: 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

示例11: 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;
            const string query = "mausch";
            var highlightQuery = new SolrQuery(query);
            var q = new Dictionary<string, string>();
            q["q"] = "";
            q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
            q["hl"] = "true";
            q["hl.q"] = query;
            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 DefaultQuerySerializer(new MSolrFieldSerializer());

            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,
                    Query = highlightQuery,
                    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:Jo1nes,项目名称:SolrNet,代码行数:61,代码来源:SolrQueryExecuterTests.cs

示例12: GetCollapseExpandParameters_min_policy

 public void GetCollapseExpandParameters_min_policy()
 {
     var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var e = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null);
     var max = new CollapseExpandParameters.MinOrMax.Max("maxfield");
     var policy = CollapseExpandParameters.NullPolicyType.Collapse;
     var p = e.GetAllParameters(SolrQuery.All, new QueryOptions {
         Rows = 1,
         CollapseExpand = new CollapseExpandParameters("somefield", null, max, policy),
     }).ToList();
     CollectionAssert.Contains(p, KV.Create("fq", "{!collapse field=somefield nullPolicy=collapse max=maxfield}"));
 }
开发者ID:jamesbdarcy,项目名称:SolrNet,代码行数:12,代码来源:SolrQueryExecuterTests.cs

示例13: GetCollapseExpandParameters_Expand

        public void GetCollapseExpandParameters_Expand()
        {
            var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
            var e = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null);
            var expand = new ExpandParameters(
                sort: new SortOrder("sortField", Order.ASC),
                rows: 100,
                query: new SolrQuery("aquery"),
                filterQuery: null);

            var p = e.GetAllParameters(SolrQuery.All, new QueryOptions {
                Rows = 1,
                CollapseExpand = new CollapseExpandParameters("somefield", expand, null, null),
            }).ToList();
            CollectionAssert.Contains(p, KV.Create("fq", "{!collapse field=somefield}"));
            CollectionAssert.Contains(p, KV.Create("expand.sort", "sortField asc"));
            CollectionAssert.Contains(p, KV.Create("expand.rows", "100"));
            CollectionAssert.Contains(p, KV.Create("expand.q", "aquery"));
        }
开发者ID:jamesbdarcy,项目名称:SolrNet,代码行数:19,代码来源:SolrQueryExecuterTests.cs

示例14: GetCollapseExpandParameters

 public void GetCollapseExpandParameters()
 {
     var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var e = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null);
     var p = e.GetAllParameters(SolrQuery.All, new QueryOptions {
         Rows = 1,
         CollapseExpand = new CollapseExpandParameters("somefield", null, null, null),
     }).ToList();
     CollectionAssert.Contains(p, KV.Create("fq", "{!collapse field=somefield}"));
 }
开发者ID:jamesbdarcy,项目名称:SolrNet,代码行数:10,代码来源:SolrQueryExecuterTests.cs

示例15: 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


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