mirror of https://github.com/apache/lucene.git
SOLR-2993: revert r1346116
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1346168 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
33b5881f21
commit
848a7cc01b
|
@ -19,7 +19,6 @@ package org.apache.solr.spelling;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -136,12 +135,8 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
|
||||||
//TODO: This just interleaves the results. In the future, we might want to let users give each checker its
|
//TODO: This just interleaves the results. In the future, we might want to let users give each checker its
|
||||||
// own weight and use that in combination to score & frequency to sort the results ?
|
// own weight and use that in combination to score & frequency to sort the results ?
|
||||||
private SpellingResult mergeCheckers(SpellingResult[] results, int numSug) {
|
private SpellingResult mergeCheckers(SpellingResult[] results, int numSug) {
|
||||||
Map<Token, Integer> combinedTokenFrequency = new HashMap<Token, Integer>();
|
|
||||||
Map<Token, List<LinkedHashMap<String, Integer>>> allSuggestions = new LinkedHashMap<Token, List<LinkedHashMap<String, Integer>>>();
|
Map<Token, List<LinkedHashMap<String, Integer>>> allSuggestions = new LinkedHashMap<Token, List<LinkedHashMap<String, Integer>>>();
|
||||||
for(SpellingResult result : results) {
|
for(SpellingResult result : results) {
|
||||||
if(result.getTokenFrequency()!=null) {
|
|
||||||
combinedTokenFrequency.putAll(result.getTokenFrequency());
|
|
||||||
}
|
|
||||||
for(Map.Entry<Token, LinkedHashMap<String, Integer>> entry : result.getSuggestions().entrySet()) {
|
for(Map.Entry<Token, LinkedHashMap<String, Integer>> entry : result.getSuggestions().entrySet()) {
|
||||||
List<LinkedHashMap<String, Integer>> allForThisToken = allSuggestions.get(entry.getKey());
|
List<LinkedHashMap<String, Integer>> allForThisToken = allSuggestions.get(entry.getKey());
|
||||||
if(allForThisToken==null) {
|
if(allForThisToken==null) {
|
||||||
|
@ -166,10 +161,6 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
|
||||||
anyData = true;
|
anyData = true;
|
||||||
Map.Entry<String,Integer> corr = iter.next();
|
Map.Entry<String,Integer> corr = iter.next();
|
||||||
combinedResult.add(original, corr.getKey(), corr.getValue());
|
combinedResult.add(original, corr.getKey(), corr.getValue());
|
||||||
Integer tokenFrequency = combinedTokenFrequency.get(original);
|
|
||||||
if(tokenFrequency!=null) {
|
|
||||||
combinedResult.addFrequency(original, tokenFrequency);
|
|
||||||
}
|
|
||||||
if(++numberAdded==numSug) {
|
if(++numberAdded==numSug) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -180,8 +171,6 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return combinedResult;
|
return combinedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1245,7 +1245,7 @@
|
||||||
collations (re-written queries) can include a combination of
|
collations (re-written queries) can include a combination of
|
||||||
corrections from both spellcheckers -->
|
corrections from both spellcheckers -->
|
||||||
<str name="spellcheck.dictionary">default</str>
|
<str name="spellcheck.dictionary">default</str>
|
||||||
<str name="spellcheck.dictionary">wordbreak</str>
|
<!--str name="spellcheck.dictionary">wordbreak</str-->
|
||||||
<str name="spellcheck">on</str>
|
<str name="spellcheck">on</str>
|
||||||
<str name="spellcheck.extendedResults">true</str>
|
<str name="spellcheck.extendedResults">true</str>
|
||||||
<str name="spellcheck.count">10</str>
|
<str name="spellcheck.count">10</str>
|
||||||
|
|
|
@ -56,9 +56,10 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {
|
||||||
server.add(doc);
|
server.add(doc);
|
||||||
server.commit(true, true);
|
server.commit(true, true);
|
||||||
|
|
||||||
SolrQuery query = new SolrQuery("name:samsang");
|
SolrQuery query = new SolrQuery("*:*");
|
||||||
query.set(CommonParams.QT, "/spell");
|
query.set(CommonParams.QT, "/spell");
|
||||||
query.set("spellcheck", true);
|
query.set("spellcheck", true);
|
||||||
|
query.set(SpellingParams.SPELLCHECK_Q, "samsang");
|
||||||
query.set(SpellingParams.SPELLCHECK_BUILD, true);
|
query.set(SpellingParams.SPELLCHECK_BUILD, true);
|
||||||
QueryRequest request = new QueryRequest(query);
|
QueryRequest request = new QueryRequest(query);
|
||||||
SpellCheckResponse response = request.process(server).getSpellCheckResponse();
|
SpellCheckResponse response = request.process(server).getSpellCheckResponse();
|
||||||
|
|
Loading…
Reference in New Issue