Apache Solr open-source search software
SOLR-2950: QEC comparator bug fixes, including deleted docs handling
Yonik Seeleyb323c54f6a61
diff --git a/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java b/lucene/src/java/org/apache/lucene/util/SentinelIntSet.javaindex 6a2e62ba209..6ca12bc7ed3 100644--- a/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java+++ b/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java@@ -30,6 +30,11 @@ public class SentinelIntSet {public final int emptyVal;public int rehashCount; // the count at which a rehash should be done+ /**+ *+ * @param size The minimum number of elements this set should be able to hold without re-hashing (i.e. the slots are guaranteed not to change)+ * @param emptyVal The integer value to use for EMPTY+ */public SentinelIntSet(int size, int emptyVal) {this.emptyVal = emptyVal;int tsize = Math.max(org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo(size), 1);diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.javaindex 30260ddf60b..e87a80a2f27 100644--- a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java@@ -25,6 +25,7 @@ import org.apache.lucene.document.DocumentStoredFieldVisitor;import org.apache.lucene.index.*;import org.apache.lucene.index.IndexReader.AtomicReaderContext;import org.apache.lucene.search.*;+import org.apache.lucene.util.Bits;import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.SentinelIntSet;import org.apache.lucene.util.automaton.Automaton;@@ -518,18 +519,23 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore//convert the ids to Lucene doc ids, the ordSet and termValues needs to be the same size as the number of elevation docs we haveordSet.clear();Fields fields = context.reader.fields();+ if (fields == null) return this;Terms terms = fields.terms(fieldname);+ if (terms == null) return this;termsEnum = terms.iterator(termsEnum);BytesRef term = new BytesRef();+ Bits liveDocs = context.reader.getLiveDocs();for (String id : elevations.ids) {term.copyChars(id);if (seen.contains(id) == false && termsEnum.seekExact(term, false)) {- docsEnum = termsEnum.docs(null, docsEnum, false);+ docsEnum = termsEnum.docs(liveDocs, docsEnum, false);if (docsEnum != null) {int docId = docsEnum.nextDoc();+ if (docId == DocIdSetIterator.NO_MORE_DOCS ) continue; // must have been deletedtermValues[ordSet.put(docId)] = BytesRef.deepCopyOf(term);seen.add(id);+ assert docsEnum.nextDoc() == DocIdSetIterator.NO_MORE_DOCS;}}}