org.apache.solr.common.params.SpellingParams Java Examples
The following examples show how to use
org.apache.solr.common.params.SpellingParams.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSpellCheckResponse.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testSpellCheckResponse() throws Exception { getSolrClient(); client.deleteByQuery("*:*"); client.commit(true, true); SolrInputDocument doc = new SolrInputDocument(); doc.setField("id", "111"); doc.setField(field, "Samsung"); client.add(doc); client.commit(true, true); SolrQuery query = new SolrQuery("*:*"); query.set(CommonParams.QT, "/spell"); query.set("spellcheck", true); query.set(SpellingParams.SPELLCHECK_Q, "samsang"); QueryRequest request = new QueryRequest(query); SpellCheckResponse response = request.process(client).getSpellCheckResponse(); Assert.assertEquals("samsung", response.getFirstSuggestion("samsang")); }
Example #2
Source File: TestFuzzyAnalyzedSuggestions.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testWithMaxEdit2() throws Exception { assertQ(req("qt", URI_MIN_EDIT_2, "q", "chagn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[2][.='change']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagn']/arr[@name='suggestion']/str[3][.='charge']" ); assertQ(req("qt", URI_MIN_EDIT_2, "q", "chagr", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[2][.='change']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chagr']/arr[@name='suggestion']/str[3][.='charge']" ); assertQ(req("qt", URI_MIN_EDIT_2, "q", "chacn", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[1][.='chance']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[2][.='change']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='chacn']/arr[@name='suggestion']/str[3][.='charge']" ); }
Example #3
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testPhrase() throws IOException, Exception { assertQ(req(CommonParams.QT, "standard", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='7']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']" ,"//arr[@name='extended_spellchecker_suggestions']/str[2][.='foo:bono AND foo:marley']" ); }
Example #4
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testSingleWord() { assertQ(req(CommonParams.QT, "standard", CommonParams.Q, "foo:bon", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='8']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob']" ,"//arr[@name='extended_spellchecker_suggestions']/str[2][.='foo:bono']" ,"//lst[@name='extended_spellchecker_suggestions_hit_counts']/long[@name='foo:bob'][.='8']" ,"//lst[@name='extended_spellchecker_suggestions_hit_counts']/long[@name='foo:bono'][.='4']" ,"//result[@name='spellchecked_response']/doc[1]/str[@name='id'][.='2']" ,"//result[@name='spellchecked_response']/doc[2]/str[@name='id'][.='3']" ,"//result[@name='spellchecked_response']/doc[3]/str[@name='id'][.='5']" ,"//result[@name='spellchecked_response']/doc[4]/str[@name='id'][.='7']" ,"//result[@name='spellchecked_response']/doc[5]/str[@name='id'][.='8']" ,"//result[@name='spellchecked_response']/doc[6]/str[@name='id'][.='9']" ,"//result[@name='spellchecked_response']/doc[7]/str[@name='id'][.='10']" ,"//result[@name='spellchecked_response']/doc[8]/str[@name='id'][.='11']"); }
Example #5
Source File: TestAnalyzedSuggestions.java From lucene-solr with Apache License 2.0 | 6 votes |
public void test() { assertQ(req("qt", URI, "q", "hokk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='hokk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='hokk']/arr[@name='suggestion']/str[1][.='北海道']" ); assertQ(req("qt", URI, "q", "ほっk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ほっk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ほっk']/arr[@name='suggestion']/str[1][.='北海道']" ); assertQ(req("qt", URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/arr[@name='suggestion']/str[1][.='北海道']" ); assertQ(req("qt", URI, "q", "ホッk", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ホッk']/arr[@name='suggestion']/str[1][.='北海道']" ); }
Example #6
Source File: SpellCheckComponentTest.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testCorrectSpelling() throws Exception { // Make sure correct spellings are signaled in the response assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","lowerfilt:lazy lowerfilt:brown", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true") ,"/spellcheck/correctlySpelled==true" ); assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", "direct_lowerfilt", "q","lowerfilt:lazy lowerfilt:brown", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true") ,"/spellcheck/correctlySpelled==true" ); assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", "direct_lowerfilt", "q","lakkle", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true") ,"/spellcheck/correctlySpelled==false" ); }
Example #7
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testFacetAndHighlight() { assertQ(req(CommonParams.QT, "standardGoodSuggestion", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", FacetParams.FACET, "true", FacetParams.FACET_FIELD, "foo", FacetParams.FACET_FIELD, "id", FacetParams.FACET_FIELD, "bar", FacetParams.FACET_QUERY, "id:[0 TO 20]", FacetParams.FACET_QUERY, "id:[1 TO 100]", HighlightParams.HIGHLIGHT, "true", HighlightParams.FIELDS, "foo", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='7']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='7']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='7']" ,"//lst[@name='spellchecked_highlighting']/lst[@name='2']/arr[@name='foo']/str[1]"); }
Example #8
Source File: TestAnalyzeInfixSuggestions.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testSingle() throws Exception { assertQ(req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']" ); assertQ(req("qt", URI_DEFAULT, "q", "high", SpellingParams.SPELLCHECK_COUNT, "1"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='high']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='high']/arr[@name='suggestion']/str[1][.='Japanese Autocomplete and Japanese <b>High</b>lighter broken']" ); /* equivalent SolrSuggester, SuggestComponent tests */ assertQ(req("qt", URI_SUGGEST_DEFAULT, "q", "japan", SuggesterParams.SUGGEST_COUNT, "1", SuggesterParams.SUGGEST_DICT, "analyzing_infix_suggest_default"), "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/int[@name='numFound'][.='1']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']" ); assertQ(req("qt", URI_SUGGEST_DEFAULT, "q", "high", SuggesterParams.SUGGEST_COUNT, "1", SuggesterParams.SUGGEST_DICT, "analyzing_infix_suggest_default"), "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='high']/int[@name='numFound'][.='1']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='high']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='Japanese Autocomplete and Japanese <b>High</b>lighter broken']" ); }
Example #9
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testFacetAndHighlightWithCommonMisspellings() { assertQ(req(CommonParams.QT, "standardResWithCommonMisspellings", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", FacetParams.FACET, "true", FacetParams.FACET_FIELD, "foo", FacetParams.FACET_FIELD, "id", FacetParams.FACET_FIELD, "bar", FacetParams.FACET_QUERY, "id:[0 TO 20]", FacetParams.FACET_QUERY, "id:[1 TO 100]", HighlightParams.HIGHLIGHT, "true", HighlightParams.FIELDS, "foo", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='3']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bono AND foo:marley']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='bob'][.='3']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='marley'][.='3']" ,"//lst[@name='spellchecked_highlighting']/lst[@name='9']/arr[@name='foo']/str[1]" ); }
Example #10
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testPhraseWithCorrectionHighlighting() { assertQ(req(CommonParams.QT, "standard", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", AbstractReSearcherComponent.RES_HIGHLIGHT_REPLACED_TAG_PARAM_NAME, "b", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='7']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']" ,"//arr[@name='extended_spellchecker_suggestions']/str[2][.='foo:bono AND foo:marley']" ,"//arr[@name='extended_spellchecker_suggestions_highlighted']/str[1][.='<b>foo:bob</b> AND foo:marley']" ,"//arr[@name='extended_spellchecker_suggestions_highlighted']/str[2][.='<b>foo:bono</b> AND foo:marley']" ); }
Example #11
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test public void testBugWithMultipleIncorrectWords() { // the bug occurs only when the second word is the one that should be changed assertQ(req(CommonParams.QT, "standardIgnoreCollation", CommonParams.Q, "foo:marlex AND foo:bobo", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='response'][@numFound='0']" ); // it is enough to see that exception didn't occur; since both words are incorrect and ReS currently handles only one // incorrect word, just one word will be fixed which still isn't enough to get any results (so suggestions wont be // returned either). }
Example #12
Source File: TestDistributedDymReSearcher.java From solr-researcher with Apache License 2.0 | 6 votes |
@Test @ShardsFixed(num = 2) public void test() throws Exception { handle.clear(); handle.put("QTime", SKIPVAL); handle.put("timestamp", SKIPVAL); handle.put("maxScore", SKIPVAL); handle.put("responseHeader", SKIP); handle.put("spellchecked_response", UNORDERED); query(CommonParams.QT, "standardResWithCommonMisspellings", ShardParams.SHARDS_QT, "standardResWithCommonMisspellings", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true"); }
Example #13
Source File: TestSpellCheckResponse.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testSpellCheckResponse_Extended() throws Exception { getSolrClient(); client.deleteByQuery("*:*"); client.commit(true, true); SolrInputDocument doc = new SolrInputDocument(); doc.setField("id", "111"); doc.setField(field, "Samsung"); client.add(doc); client.commit(true, true); SolrQuery query = new SolrQuery("*:*"); query.set(CommonParams.QT, "/spell"); query.set("spellcheck", true); query.set(SpellingParams.SPELLCHECK_Q, "samsang"); query.set(SpellingParams.SPELLCHECK_EXTENDED_RESULTS, true); QueryRequest request = new QueryRequest(query); SpellCheckResponse response = request.process(client).getSpellCheckResponse(); assertEquals("samsung", response.getFirstSuggestion("samsang")); SpellCheckResponse.Suggestion sug = response.getSuggestion("samsang"); List<SpellCheckResponse.Suggestion> sugs = response.getSuggestions(); assertEquals(sug.getAlternatives().size(), sug.getAlternativeFrequencies().size()); assertEquals(sugs.get(0).getAlternatives().size(), sugs.get(0).getAlternativeFrequencies().size()); assertEquals("samsung", sug.getAlternatives().get(0)); assertEquals("samsung", sugs.get(0).getAlternatives().get(0)); // basic test if fields were filled in assertTrue(sug.getEndOffset()>0); assertTrue(sug.getToken().length() > 0); assertTrue(sug.getNumFound() > 0); // assertTrue(sug.getOriginalFrequency() > 0); // Hmmm... the API for SpellCheckResponse could be nicer: response.getSuggestions().get(0).getAlternatives().get(0); }
Example #14
Source File: DirectSolrSpellCheckerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testOnlyMorePopularWithExtendedResults() throws Exception { assertQ(req("q", "teststop:fox", "qt", "/spellCheckCompRH", SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_DICT, "direct", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='fox']/int[@name='origFreq']=1", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='fox']/arr[@name='suggestion']/lst/str[@name='word']='foo'", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='fox']/arr[@name='suggestion']/lst/int[@name='freq']=2", "//lst[@name='spellcheck']/bool[@name='correctlySpelled']='true'" ); }
Example #15
Source File: SpellCheckCollatorWithCollapseTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { for(int i=0 ; i<200 ; i++) { String[] doc = {"id","" + i, "group_i", "" + (i % 10), "a_s", ((i%2)==0 ? "love" : "peace")}; assertU(adoc(doc)); if(i%5==0) { assertU(commit()); } } assertU(commit()); for (SolrParams params : new SolrParams[]{ params(CommonParams.FQ, "{!collapse field=group_i}"), params(CommonParams.FQ, "${bleh}", "bleh", "{!collapse field=group_i}"), // substitution params(CommonParams.FQ, "{!tag=collapser}{!collapse field=group_i}"), // with tag & collapse in localparams params(CommonParams.FQ, "{!collapse tag=collapser field=group_i}") }) { assertQ( req(params, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_DICT, "direct", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1", CommonParams.Q, "a_s:lpve", CommonParams.QT, "/spellCheckCompRH_Direct", SpellingParams.SPELLCHECK_COLLATE_MAX_COLLECT_DOCS, "5", "expand", "true"), "//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='a_s:love'" ); } }
Example #16
Source File: TestPhraseSuggestions.java From lucene-solr with Apache License 2.0 | 5 votes |
public void test() { assertQ(req("qt", URI, "q", "the f", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[1][.='the final phrase']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[2][.='the fifth phrase']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='the f']/arr[@name='suggestion']/str[3][.='the first phrase']" ); assertQ(req("qt", URI, "q", "Testing +12", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='testing 12']/int[@name='numFound'][.='1']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='testing 12']/arr[@name='suggestion']/str[1][.='testing 1234']" ); }
Example #17
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollationWithRangeQuery() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "10"); params.add(CommonParams.Q, "id:[1 TO 10] AND lowerfilt:lovw"); { SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size()==1); String collation = collations.iterator().next(); System.out.println(collation); assertTrue("Incorrect collation: " + collation,"id:[1 TO 10] AND lowerfilt:love".equals(collation)); } }
Example #18
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testCollateWithOverride() throws Exception { assertQ( req( SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_DICT, "direct", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10", "qt", "/spellCheckCompRH", "defType", "edismax", "qf", "teststop", "mm", "1", CommonParams.Q, "partisian politcal mashine" ), "//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='parisian political machine'" ); assertQ( req( SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_DICT, "direct", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10", "qt", "/spellCheckCompRH", "defType", "edismax", "qf", "teststop", "mm", "1", SpellingParams.SPELLCHECK_COLLATE_PARAM_OVERRIDE + "mm", "100%", CommonParams.Q, "partisian politcal mashine" ), "//lst[@name='spellcheck']/lst[@name='collations']/str[@name='collation']='partisan political machine'" ); }
Example #19
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollateWithFilter() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10"); params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)"); params.add(CommonParams.FQ, "NOT(id:1)"); //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1. SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size() > 0); for(String collation : collations) { assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)")); } }
Example #20
Source File: SpellCheckCollatorTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testCollateWithGrouping() throws Exception { SolrCore core = h.getCore(); SearchComponent speller = core.getSearchComponent("spellcheck"); assertTrue("speller is null and it shouldn't be", speller != null); ModifiableSolrParams params = new ModifiableSolrParams(); params.add(SpellCheckComponent.COMPONENT_NAME, "true"); params.add(SpellingParams.SPELLCHECK_BUILD, "true"); params.add(SpellingParams.SPELLCHECK_COUNT, "10"); params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5"); params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1"); params.add(CommonParams.Q, "lowerfilt:(+fauth)"); params.add(GroupParams.GROUP, "true"); params.add(GroupParams.GROUP_FIELD, "id"); //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1. SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH"); SolrQueryResponse rsp = new SolrQueryResponse(); rsp.addResponseHeader(new SimpleOrderedMap()); SolrQueryRequest req = new LocalSolrQueryRequest(core, params); handler.handleRequest(req, rsp); req.close(); NamedList values = rsp.getValues(); NamedList spellCheck = (NamedList) values.get("spellcheck"); NamedList collationHolder = (NamedList) spellCheck.get("collations"); List<String> collations = collationHolder.getAll("collation"); assertTrue(collations.size() == 1); }
Example #21
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 5 votes |
@Test public void testQueryCorrectlySpelled() { assertQ(req(CommonParams.QT, "standard", CommonParams.Q, "foo:bob AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='response'][@numFound='7']"); }
Example #22
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 5 votes |
@Test public void testPhraseWithGoodSuggestionAlgorithm() { assertQ(req(CommonParams.QT, "standardGoodSuggestion", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='7']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bob AND foo:marley']"); }
Example #23
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 5 votes |
@Test public void testOriginalAndSpellcheckedFacet() { assertQ(req(CommonParams.QT, "standardGoodSuggestionAllowSomeOriginalResults", CommonParams.Q, "foo:elvos OR foo:presley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", FacetParams.FACET, "true", FacetParams.FACET_FIELD, "foo", FacetParams.FACET_FIELD, "id", FacetParams.FACET_FIELD, "bar", FacetParams.FACET_QUERY, "id:[0 TO 20]", FacetParams.FACET_QUERY, "id:[1 TO 100]", HighlightParams.HIGHLIGHT, "true", HighlightParams.FIELDS, "foo", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='3']" ,"//result[@name='response'][@numFound='1']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:elvis OR foo:presley']" // check spellchecked facets: ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='elvi'][.='3']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='presley'][.='1']" ,"//lst[@name='spellchecked_facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='2'][.='1']" // check original facets: ,"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='elvi'][.='1']" ,"//lst[@name='facet_counts']/lst[@name='facet_fields']/lst[@name='foo']/int[@name='presley'][.='1']" ); }
Example #24
Source File: TestDymReSearcher.java From solr-researcher with Apache License 2.0 | 5 votes |
@Test public void testPhraseWithFgsAndCommonMisspellings() { assertQ(req(CommonParams.QT, "standardResWithCommonMisspellings", CommonParams.Q, "foo:bobo AND foo:marley", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_BUILD, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", DymReSearcher.COMPONENT_NAME, "true", SpellCheckComponent.COMPONENT_NAME, "true") ,"//result[@name='spellchecked_response'][@numFound='3']" ,"//result[@name='response'][@numFound='0']" ,"//arr[@name='extended_spellchecker_suggestions']/str[1][.='foo:bono AND foo:marley']" ); }
Example #25
Source File: TestAnalyzeInfixSuggestions.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testMultiple() throws Exception { assertQ(req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "2"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='2']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add <b>Japan</b>ese Kanji number normalization to Kuromoji']" ); assertQ(req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "3"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add <b>Japan</b>ese Kanji number normalization to Kuromoji']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[3][.='Add decompose compound <b>Japan</b>ese Katakana token capability to Kuromoji']" ); assertQ(req("qt", URI_DEFAULT, "q", "japan", SpellingParams.SPELLCHECK_COUNT, "4"), "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/int[@name='numFound'][.='3']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[1][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[2][.='Add <b>Japan</b>ese Kanji number normalization to Kuromoji']", "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='japan']/arr[@name='suggestion']/str[3][.='Add decompose compound <b>Japan</b>ese Katakana token capability to Kuromoji']" ); /* SolrSuggester, SuggestComponent tests: allTermsRequire (true), highlight (true) */ assertQ(req("qt", URI_SUGGEST_DEFAULT, "q", "japan", SuggesterParams.SUGGEST_COUNT, "2", SuggesterParams.SUGGEST_DICT, "analyzing_infix_suggest_default"), "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/int[@name='numFound'][.='2']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='<b>Japan</b>ese Autocomplete and <b>Japan</b>ese Highlighter broken']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japan']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='Add <b>Japan</b>ese Kanji number normalization to Kuromoji']" ); assertQ(req("qt", URI_SUGGEST_DEFAULT, "q", "japanese ka", SuggesterParams.SUGGEST_COUNT, "2", SuggesterParams.SUGGEST_DICT, "analyzing_infix_suggest_default"), "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japanese ka']/int[@name='numFound'][.='2']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japanese ka']/arr[@name='suggestions']/lst[1]/str[@name='term'][.='Add <b>Japanese</b> <b>Ka</b>nji number normalization to Kuromoji']", "//lst[@name='suggest']/lst[@name='analyzing_infix_suggest_default']/lst[@name='japanese ka']/arr[@name='suggestions']/lst[2]/str[@name='term'][.='Add decompose compound <b>Japanese</b> <b>Ka</b>takana token capability to Kuromoji']" ); }
Example #26
Source File: SpellCheckComponent.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * For every param that is of the form "spellcheck.[dictionary name].XXXX=YYYY, add * XXXX=YYYY as a param to the custom param list * @param params The original SolrParams * @return The new Params */ protected SolrParams getCustomParams(String dictionary, SolrParams params) { ModifiableSolrParams result = new ModifiableSolrParams(); Iterator<String> iter = params.getParameterNamesIterator(); String prefix = SpellingParams.SPELLCHECK_PREFIX + dictionary + "."; while (iter.hasNext()) { String nxt = iter.next(); if (nxt.startsWith(prefix)) { result.add(nxt.substring(prefix.length()), params.getParams(nxt)); } } return result; }
Example #27
Source File: SpellCheckComponentTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testExtendedResultsCount() throws Exception { assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","bluo", SpellingParams.SPELLCHECK_COUNT,"5", SpellingParams.SPELLCHECK_EXTENDED_RESULTS,"false") ,"/spellcheck/suggestions/[0]=='bluo'" ,"/spellcheck/suggestions/[1]/numFound==5" ); assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","bluo", SpellingParams.SPELLCHECK_COUNT,"3", SpellingParams.SPELLCHECK_EXTENDED_RESULTS,"true") ,"/spellcheck/suggestions/[1]/suggestion==[{'word':'blud','freq':1}, {'word':'blue','freq':1}, {'word':'blee','freq':1}]" ); }
Example #28
Source File: SpellCheckComponentTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testPerDictionary() throws Exception { assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","documemt" , SpellingParams.SPELLCHECK_DICT, "perDict", SpellingParams.SPELLCHECK_PREFIX + "perDict.foo", "bar", SpellingParams.SPELLCHECK_PREFIX + "perDict.bar", "foo") ,"/spellcheck/suggestions/bar=={'numFound':1, 'startOffset':0, 'endOffset':1, 'suggestion':['foo']}" ,"/spellcheck/suggestions/foo=={'numFound':1, 'startOffset':2, 'endOffset':3, 'suggestion':['bar']}" ); }
Example #29
Source File: SpellCheckComponentTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testCollate() throws Exception { assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","documemt", SpellingParams.SPELLCHECK_COLLATE, "true") ,"/spellcheck/collations/collation=='document'" ); assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","documemt lowerfilt:broen^4", SpellingParams.SPELLCHECK_COLLATE, "true") ,"/spellcheck/collations/collation=='document lowerfilt:brown^4'" ); assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","documemtsss broens", SpellingParams.SPELLCHECK_COLLATE, "true") ,"/spellcheck/collations/collation=='document brown'" ); assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","pixma", SpellingParams.SPELLCHECK_COLLATE, "true") ,"/spellcheck/collations/collation=='pixmaa'" ); }
Example #30
Source File: SpellCheckComponentTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private void implTestCollateExtendedResultsWithJsonNl(String q, String jsonNl, boolean collateExtendedResults, String ... tests) throws Exception { final SolrQueryRequest solrQueryRequest = req( CommonParams.QT, rh, CommonParams.Q, q, "json.nl", jsonNl, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, Boolean.toString(collateExtendedResults), SpellingParams.SPELLCHECK_COLLATE, "true"); assertJQ(solrQueryRequest, tests); }