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:
James Dyer 2012-06-04 21:33:36 +00:00
parent 33b5881f21
commit 848a7cc01b
3 changed files with 4 additions and 14 deletions

View File

@ -19,7 +19,6 @@ package org.apache.solr.spelling;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
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
// own weight and use that in combination to score & frequency to sort the results ?
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>>>();
for(SpellingResult result : results) {
if(result.getTokenFrequency()!=null) {
combinedTokenFrequency.putAll(result.getTokenFrequency());
}
for(Map.Entry<Token, LinkedHashMap<String, Integer>> entry : result.getSuggestions().entrySet()) {
List<LinkedHashMap<String, Integer>> allForThisToken = allSuggestions.get(entry.getKey());
if(allForThisToken==null) {
@ -166,10 +161,6 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
anyData = true;
Map.Entry<String,Integer> corr = iter.next();
combinedResult.add(original, corr.getKey(), corr.getValue());
Integer tokenFrequency = combinedTokenFrequency.get(original);
if(tokenFrequency!=null) {
combinedResult.addFrequency(original, tokenFrequency);
}
if(++numberAdded==numSug) {
break;
}
@ -180,8 +171,6 @@ public class ConjunctionSolrSpellChecker extends SolrSpellChecker {
}
}
}
return combinedResult;
}

View File

@ -1245,7 +1245,7 @@
collations (re-written queries) can include a combination of
corrections from both spellcheckers -->
<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.extendedResults">true</str>
<str name="spellcheck.count">10</str>

View File

@ -56,9 +56,10 @@ public class TestSpellCheckResponse extends SolrJettyTestBase {
server.add(doc);
server.commit(true, true);
SolrQuery query = new SolrQuery("name:samsang");
SolrQuery query = new SolrQuery("*:*");
query.set(CommonParams.QT, "/spell");
query.set("spellcheck", true);
query.set(SpellingParams.SPELLCHECK_Q, "samsang");
query.set(SpellingParams.SPELLCHECK_BUILD, true);
QueryRequest request = new QueryRequest(query);
SpellCheckResponse response = request.process(server).getSpellCheckResponse();