mirror of
https://github.com/apache/lucene.git
synced 2025-02-07 18:49:03 +00:00
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:
parent
115ef9b8dc
commit
4c724b958b
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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}]"
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user