mirror of https://github.com/apache/lucene.git
SOLR-1928: fix terms component index order tiebreak
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@948299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e61dd591f
commit
9d4bd2af41
|
@ -307,6 +307,10 @@ Bug Fixes
|
||||||
* SOLR-1824: IndexSchema will now fail to initialize if there is a
|
* SOLR-1824: IndexSchema will now fail to initialize if there is a
|
||||||
problem initializing one of the fields or field types. (hossman)
|
problem initializing one of the fields or field types. (hossman)
|
||||||
|
|
||||||
|
* SOLR-1928: TermsComponent didn't correctly break ties for non-text
|
||||||
|
fields sorted by count. (yonik)
|
||||||
|
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class TermsComponent extends SearchComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
BoundedTreeSet<CountPair<String, Integer>> queue = (sort ? new BoundedTreeSet<CountPair<String, Integer>>(limit) : null);
|
BoundedTreeSet<CountPair<BytesRef, Integer>> queue = (sort ? new BoundedTreeSet<CountPair<BytesRef, Integer>>(limit) : null);
|
||||||
CharArr external = new CharArr();
|
CharArr external = new CharArr();
|
||||||
|
|
||||||
while (term != null && (i<limit || sort)) {
|
while (term != null && (i<limit || sort)) {
|
||||||
|
@ -194,19 +194,18 @@ public class TermsComponent extends SearchComponent {
|
||||||
int docFreq = termsEnum.docFreq();
|
int docFreq = termsEnum.docFreq();
|
||||||
if (docFreq >= freqmin && docFreq <= freqmax) {
|
if (docFreq >= freqmin && docFreq <= freqmax) {
|
||||||
// add the term to the list
|
// add the term to the list
|
||||||
|
|
||||||
// TODO: handle raw somehow
|
|
||||||
if (!externalized) {
|
|
||||||
external.reset();
|
|
||||||
ft.indexedToReadable(term, external);
|
|
||||||
}
|
|
||||||
|
|
||||||
String label = external.toString();
|
|
||||||
if (sort) {
|
if (sort) {
|
||||||
// TODO: defer conversion to string until the end...
|
queue.add(new CountPair<BytesRef, Integer>(new BytesRef(term), docFreq));
|
||||||
// using the label now is a bug since tiebreak will not be in index order
|
|
||||||
queue.add(new CountPair<String, Integer>(label, docFreq));
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// TODO: handle raw somehow
|
||||||
|
if (!externalized) {
|
||||||
|
external.reset();
|
||||||
|
ft.indexedToReadable(term, external);
|
||||||
|
}
|
||||||
|
String label = external.toString();
|
||||||
|
|
||||||
|
|
||||||
fieldTerms.add(label, docFreq);
|
fieldTerms.add(label, docFreq);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -216,9 +215,11 @@ public class TermsComponent extends SearchComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort) {
|
if (sort) {
|
||||||
for (CountPair<String, Integer> item : queue) {
|
for (CountPair<BytesRef, Integer> item : queue) {
|
||||||
if (i >= limit) break;
|
if (i >= limit) break;
|
||||||
fieldTerms.add(item.key, item.val);
|
external.reset();
|
||||||
|
ft.indexedToReadable(item.key, external);
|
||||||
|
fieldTerms.add(external.toString(), item.val);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue