diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1efd058d9ca..d9904c6edf2 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -307,6 +307,10 @@ Bug Fixes * SOLR-1824: IndexSchema will now fail to initialize if there is a 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 ---------------------- diff --git a/solr/src/java/org/apache/solr/handler/component/TermsComponent.java b/solr/src/java/org/apache/solr/handler/component/TermsComponent.java index 8eef7439fab..3386b81bfa3 100644 --- a/solr/src/java/org/apache/solr/handler/component/TermsComponent.java +++ b/solr/src/java/org/apache/solr/handler/component/TermsComponent.java @@ -164,7 +164,7 @@ public class TermsComponent extends SearchComponent { } int i = 0; - BoundedTreeSet> queue = (sort ? new BoundedTreeSet>(limit) : null); + BoundedTreeSet> queue = (sort ? new BoundedTreeSet>(limit) : null); CharArr external = new CharArr(); while (term != null && (i= freqmin && docFreq <= freqmax) { // add the term to the list - - // TODO: handle raw somehow - if (!externalized) { - external.reset(); - ft.indexedToReadable(term, external); - } - - String label = external.toString(); if (sort) { - // TODO: defer conversion to string until the end... - // using the label now is a bug since tiebreak will not be in index order - queue.add(new CountPair(label, docFreq)); + queue.add(new CountPair(new BytesRef(term), docFreq)); } else { + + // TODO: handle raw somehow + if (!externalized) { + external.reset(); + ft.indexedToReadable(term, external); + } + String label = external.toString(); + + fieldTerms.add(label, docFreq); i++; } @@ -216,9 +215,11 @@ public class TermsComponent extends SearchComponent { } if (sort) { - for (CountPair item : queue) { + for (CountPair item : queue) { if (i >= limit) break; - fieldTerms.add(item.key, item.val); + external.reset(); + ft.indexedToReadable(item.key, external); + fieldTerms.add(external.toString(), item.val); i++; } }