elasticsearch/elasticsearch — pull request #5978 by mikemccand (2014-04-29 11:55:47+00:00)
Title: tie-break suggestions by term

OK, DirectCandidateGenerator.CandidateSet.candidates also required
tie-breaking because CandidateScorer.findBestCandidates would change
its results depending on the sort order of the candidates in each
CandidateSet. And it was tricky because the tests would
intermittently fail since BytesRef.hashCode is different for
every JVM instance...

So I added an Arrays.sort in addCandidates, and fixed Correction and
Candidate to implement Comparable, and fixed CandidateScorer.updateTop
to use .compareTo when checking if the new correction competes with
the top of the PQ.

I folded in Simon's comment as-is into SuggestSearchTests, but I still
don't fully understand the test, e.g. why after
"phraseSuggestion.analyzer(null);" would this get bigram to
participate in scoring again? (The previous test did
.forceUnigrams(true) which I think is why xorn/xorr were tied for score).