mirror of https://github.com/apache/lucene.git
SOLR-2950: QEC comparator bug fixes, including deleted docs handling
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1221826 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e14cda1489
commit
b323c54f6a
|
@ -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);
|
||||
|
|
|
@ -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 have
|
||||
ordSet.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 deleted
|
||||
termValues[ordSet.put(docId)] = BytesRef.deepCopyOf(term);
|
||||
seen.add(id);
|
||||
assert docsEnum.nextDoc() == DocIdSetIterator.NO_MORE_DOCS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue