SOLR-2257: fix contrib/spellchecker to be deterministic by adding a tertiary comparison (term text)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1040064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-11-29 11:07:05 +00:00
parent 115ef9b8dc
commit 4c724b958b
4 changed files with 6 additions and 4 deletions

View File

@ -41,6 +41,7 @@ public class SuggestWordFrequencyComparator implements Comparator<SuggestWord> {
if (first.score < second.score) {
return -1;
}
return 0;
// third criteria: term text
return second.string.compareTo(first.string);
}
}

View File

@ -41,6 +41,7 @@ public class SuggestWordScoreComparator implements Comparator<SuggestWord> {
if (first.freq < second.freq) {
return -1;
}
return 0;
// third criteria: term text
return second.string.compareTo(first.string);
}
}

View File

@ -39,7 +39,7 @@ public class TestPlainTextDictionary extends LuceneTestCase {
String[] similar = spellChecker.suggestSimilar("treeword", 2);
assertEquals(2, similar.length);
assertEquals(similar[0], "threeword");
assertEquals(similar[1], "twoword");
assertEquals(similar[1], "oneword");
spellChecker.close();
ramDir.close();
}

View File

@ -66,7 +66,7 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
);
assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","bluo", SpellCheckComponent.SPELLCHECK_COUNT,"3", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS,"true")
,"/spellcheck/suggestions/[1]/suggestion==[{'word':'blue','freq':1}, {'word':'blud','freq':1}, {'word':'boue','freq':1}]"
,"/spellcheck/suggestions/[1]/suggestion==[{'word':'blud','freq':1}, {'word':'blue','freq':1}, {'word':'blee','freq':1}]"
);
}