From 9d4bd2af4130bb573862315a60e94ff5e0e9b9e6 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Wed, 26 May 2010 03:02:59 +0000 Subject: [PATCH] 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 --- solr/CHANGES.txt | 4 +++ .../handler/component/TermsComponent.java | 29 ++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) 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++; } }