public void GetClusteringParameters() { var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter <TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { Clustering = new ClusteringParameters { Title = "headline", FragSize = 10, LexicalResources = "fakedir", ProduceSummary = true, Algorithm = "org.carrot2.clustering.lingo.LingoClusteringAlgorithm", Url = "none", Collection = false, Engine = "default", SubClusters = false, Snippet = "synopsis", NumDescriptions = 20 }, }).ToList(); Assert.Contains(p, KV.Create("carrot.title", "headline")); Assert.Contains(p, KV.Create("clustering.engine", "default")); Assert.Contains(p, KV.Create("clustering.collection", "false")); Assert.Contains(p, KV.Create("carrot.algorithm", "org.carrot2.clustering.lingo.LingoClusteringAlgorithm")); Assert.Contains(p, KV.Create("carrot.url", "none")); Assert.Contains(p, KV.Create("carrot.snippet", "synopsis")); Assert.Contains(p, KV.Create("carrot.produceSummary", "true")); Assert.Contains(p, KV.Create("carrot.fragSize", "10")); Assert.Contains(p, KV.Create("carrot.numDescriptions", "20")); Assert.Contains(p, KV.Create("carrot.outputSubClusters", "false")); Assert.Contains(p, KV.Create("carrot.lexicalResourcesDir", "fakedir")); }
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 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") } }); }); }
public void FacetFieldOptions() { var querySerializer = new SolrQuerySerializerStub("q"); var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, null); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, facetQuerySerializer, null); var facetOptions = queryExecuter.GetFacetFieldOptions( new FacetParameters { Queries = new List<ISolrFacetQuery> { new SolrFacetQuery(new SolrQuery("q")), }, Prefix = "pref", EnumCacheMinDf = 123, Limit = 100, MinCount = 5, Missing = true, Offset = 55, Sort = true, }).ToDictionary(x => x.Key, x => x.Value); Assert.AreEqual("pref", facetOptions["facet.prefix"]); Assert.AreEqual("123", facetOptions["facet.enum.cache.minDf"]); Assert.AreEqual("100", facetOptions["facet.limit"]); Assert.AreEqual("5", facetOptions["facet.mincount"]); Assert.AreEqual("true", facetOptions["facet.missing"]); Assert.AreEqual("55", facetOptions["facet.offset"]); Assert.AreEqual("true", facetOptions["facet.sort"]); }
public void GetAllParameters_with_spelling() { var mocks = new MockRepository(); var parser = mocks.DynamicMock <ISolrQueryResultParser <TestDocument> >(); var conn = mocks.DynamicMock <ISolrConnection>(); var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter <TestDocument>(parser, conn, querySerializer, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { SpellCheck = new SpellCheckingParameters { Query = "hell", Build = true, Collate = true, Count = 4, Dictionary = "spanish", OnlyMorePopular = true, Reload = true, }, }).ToList(); Assert.Contains(p, KVP("spellcheck", "true")); Assert.Contains(p, KVP("spellcheck.q", "hell")); Assert.Contains(p, KVP("spellcheck.build", "true")); Assert.Contains(p, KVP("spellcheck.collate", "true")); Assert.Contains(p, KVP("spellcheck.count", "4")); Assert.Contains(p, KVP("spellcheck.dictionary", "spanish")); Assert.Contains(p, KVP("spellcheck.onlyMorePopular", "true")); Assert.Contains(p, KVP("spellcheck.reload", "true")); }
public void GetAllParameters_with_spelling() { var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter <TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { SpellCheck = new SpellCheckingParameters { Query = "hell", Build = true, Collate = true, Count = 4, Dictionary = "spanish", OnlyMorePopular = true, Reload = true, }, }).ToList(); Assert.Contains(p, KV.Create("spellcheck", "true")); Assert.Contains(p, KV.Create("spellcheck.q", "hell")); Assert.Contains(p, KV.Create("spellcheck.build", "true")); Assert.Contains(p, KV.Create("spellcheck.collate", "true")); Assert.Contains(p, KV.Create("spellcheck.count", "4")); Assert.Contains(p, KV.Create("spellcheck.dictionary", "spanish")); Assert.Contains(p, KV.Create("spellcheck.onlyMorePopular", "true")); Assert.Contains(p, KV.Create("spellcheck.reload", "true")); }
public void FacetFieldOptions() { var querySerializer = new SolrQuerySerializerStub("q"); var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, null); var queryExecuter = new SolrQueryExecuter <TestDocument>(null, null, querySerializer, facetQuerySerializer, null); var facetOptions = queryExecuter.GetFacetFieldOptions( new FacetParameters { Queries = new List <ISolrFacetQuery> { new SolrFacetQuery(new SolrQuery("q")), }, Prefix = "pref", EnumCacheMinDf = 123, Limit = 100, MinCount = 5, Missing = true, Offset = 55, Sort = true, }).ToDictionary(x => x.Key, x => x.Value); Assert.AreEqual("pref", facetOptions["facet.prefix"]); Assert.AreEqual("123", facetOptions["facet.enum.cache.minDf"]); Assert.AreEqual("100", facetOptions["facet.limit"]); Assert.AreEqual("5", facetOptions["facet.mincount"]); Assert.AreEqual("true", facetOptions["facet.missing"]); Assert.AreEqual("55", facetOptions["facet.offset"]); Assert.AreEqual("true", facetOptions["facet.sort"]); }
public void Highlighting() { var mocks = new MockRepository(); var parser = mocks.DynamicMock <ISolrQueryResultParser <TestDocument> >(); 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 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 } }); }
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, } }); }
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(); }
public void ExtraParams() { var querySerializer = new SolrQuerySerializerStub("123123"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("123123"), new QueryOptions { ExtraParams = new Dictionary<string, string> { {"qt", "geo"}, {"lat", "40.75141843299745"}, {"long", "-74.0093994140625"}, {"radius", "1"}, } }).ToDictionary(x => x.Key, x => x.Value); Assert.AreEqual("123123", p["q"]); Assert.AreEqual("geo", p["qt"]); Assert.AreEqual("1", p["radius"]); }
public void ExtraParams() { var querySerializer = new SolrQuerySerializerStub("123123"); var queryExecuter = new SolrQueryExecuter <TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("123123"), new QueryOptions { ExtraParams = new Dictionary <string, string> { { "qt", "geo" }, { "lat", "40.75141843299745" }, { "long", "-74.0093994140625" }, { "radius", "1" }, } }).ToDictionary(x => x.Key, x => x.Value); Assert.AreEqual("123123", p["q"]); Assert.AreEqual("geo", p["qt"]); Assert.AreEqual("1", p["radius"]); }
public void MoreLikeThis() { var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter <TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { MoreLikeThis = new MoreLikeThisParameters(new[] { "manu", "cat" }) { MinDocFreq = 1, MinTermFreq = 1, }, }).ToList(); Assert.Contains(p, KV.Create("mlt", "true")); Assert.Contains(p, KV.Create("mlt.mindf", "1")); Assert.Contains(p, KV.Create("mlt.fl", "manu,cat")); Assert.Contains(p, KV.Create("mlt.mintf", "1")); Assert.Contains(p, KV.Create("q", "apache")); }
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" }, }); }
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(); }
public void MoreLikeThis() { var mocks = new MockRepository(); var parser = mocks.DynamicMock <ISolrQueryResultParser <TestDocument> >(); var conn = mocks.DynamicMock <ISolrConnection>(); var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter <TestDocument>(parser, conn, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { MoreLikeThis = new MoreLikeThisParameters(new[] { "manu", "cat" }) { MinDocFreq = 1, MinTermFreq = 1, }, }).ToList(); Assert.Contains(p, KV.Create("mlt", "true")); Assert.Contains(p, KV.Create("mlt.mindf", "1")); Assert.Contains(p, KV.Create("mlt.fl", "manu,cat")); Assert.Contains(p, KV.Create("mlt.mintf", "1")); Assert.Contains(p, KV.Create("q", "apache")); }
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) } }); }); }
public void FacetFieldWithGroupingOptions() { var querySerializer = new SolrQuerySerializerStub("q"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var groupingQueryOptions = queryExecuter.GetGroupingQueryOptions(new QueryOptions { Grouping = new GroupingParameters { Fields = new[] { "one" }, Facet = true } }).ToList(); Assert.Contains(groupingQueryOptions, KV.Create("group.facet", "true")); }
public void GetAllParameters_with_both_group_fields_and_group_queries() { var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { Grouping = new GroupingParameters { Query = new Collection<string> { "apple", "banana", "cherry" }, Fields = new Collection<string> { "fieldx", "fieldy", "fieldz" } } }).ToList(); IEnumerable<string> groupParameters = p.Where(param => param.Key.StartsWith("group.")).Select(param => param.Key); Assert.IsEmpty(groupParameters, "The invalid combination of group.fields and group.query should not have generated any group parameters."); }
public void GetAllParameters_with_multiple_group_fields() { var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { Grouping = new GroupingParameters { Fields = new Collection<string> { "fieldx", "fieldy", "fieldz" } } }).ToList(); Assert.Contains(p, KV.Create("group.field", "fieldx")); Assert.Contains(p, KV.Create("group.field", "fieldy")); Assert.Contains(p, KV.Create("group.field", "fieldz")); }
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" }, }); }
public void MoreLikeThis() { var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { MoreLikeThis = new MoreLikeThisParameters(new[] { "manu", "cat" }) { MinDocFreq = 1, MinTermFreq = 1, }, }).ToList(); Assert.Contains(p, KV.Create("mlt", "true")); Assert.Contains(p, KV.Create("mlt.mindf", "1")); Assert.Contains(p, KV.Create("mlt.fl", "manu,cat")); Assert.Contains(p, KV.Create("mlt.mintf", "1")); Assert.Contains(p, KV.Create("q", "apache")); }
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 } }); }
public void GetClusteringParameters() { var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { Clustering = new ClusteringParameters { Title = "headline", FragSize = 10, LexicalResources = "fakedir", ProduceSummary = true, Algorithm = "org.carrot2.clustering.lingo.LingoClusteringAlgorithm", Url = "none", Collection = false, Engine = "default", SubClusters = false, Snippet = "synopsis", NumDescriptions = 20 }, }).ToList(); Assert.Contains(p, KV.Create("carrot.title", "headline")); Assert.Contains(p, KV.Create("clustering.engine", "default")); Assert.Contains(p, KV.Create("clustering.collection", "false")); Assert.Contains(p, KV.Create("carrot.algorithm", "org.carrot2.clustering.lingo.LingoClusteringAlgorithm")); Assert.Contains(p, KV.Create("carrot.url", "none")); Assert.Contains(p, KV.Create("carrot.snippet", "synopsis")); Assert.Contains(p, KV.Create("carrot.produceSummary", "true")); Assert.Contains(p, KV.Create("carrot.fragSize", "10")); Assert.Contains(p, KV.Create("carrot.numDescriptions", "20")); Assert.Contains(p, KV.Create("carrot.outputSubClusters", "false")); Assert.Contains(p, KV.Create("carrot.lexicalResourcesDir", "fakedir")); }
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"}, }); }); }
public void GetAllParameters_with_multiple_group_queries() { var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { Grouping = new GroupingParameters { Query = new Collection<string> { "apple", "banana", "cherry" } } }).ToList(); Assert.Contains(p, KV.Create("group.query", "apple") ); Assert.Contains(p, KV.Create("group.query", "banana")); Assert.Contains(p, KV.Create("group.query", "cherry")); }
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, } }); }
public void GetAllParameters_with_spelling() { var querySerializer = new SolrQuerySerializerStub("*:*"); var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null); var p = queryExecuter.GetAllParameters(SolrQuery.All, new QueryOptions { SpellCheck = new SpellCheckingParameters { Query = "hell", Build = true, Collate = true, Count = 4, Dictionary = "spanish", OnlyMorePopular = true, Reload = true, }, }).ToList(); Assert.Contains(p, KV.Create("spellcheck", "true")); Assert.Contains(p, KV.Create("spellcheck.q", "hell")); Assert.Contains(p, KV.Create("spellcheck.build", "true")); Assert.Contains(p, KV.Create("spellcheck.collate", "true")); Assert.Contains(p, KV.Create("spellcheck.count", "4")); Assert.Contains(p, KV.Create("spellcheck.dictionary", "spanish")); Assert.Contains(p, KV.Create("spellcheck.onlyMorePopular", "true")); Assert.Contains(p, KV.Create("spellcheck.reload", "true")); }
public void MoreLikeThis() { var mocks = new MockRepository(); var parser = mocks.DynamicMock<ISolrQueryResultParser<TestDocument>>(); var conn = mocks.DynamicMock<ISolrConnection>(); var querySerializer = new SolrQuerySerializerStub("apache"); var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null); var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions { MoreLikeThis = new MoreLikeThisParameters(new[] {"manu", "cat"}) { MinDocFreq = 1, MinTermFreq = 1, }, }).ToList(); Assert.Contains(p, KV.Create("mlt", "true")); Assert.Contains(p, KV.Create("mlt.mindf", "1")); Assert.Contains(p, KV.Create("mlt.fl", "manu,cat")); Assert.Contains(p, KV.Create("mlt.mintf", "1")); Assert.Contains(p, KV.Create("q", "apache")); }