mirror of https://github.com/apache/lucene.git
LUCENE-8055: MemoryIndex.MemoryDocValuesIterator returns 2 documents instead of 1
Fixes a bug if there is a DV field in the MemoryIndex the `MemoryIndex.MemoryDocValuesIterator` will return 2 documents instead of 1.
This commit is contained in:
parent
26398d2dc9
commit
a14972d7ae
|
@ -114,6 +114,11 @@ Tests
|
|||
|
||||
======================= Lucene 7.1.1 =======================
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* LUCENE-8055: MemoryIndex.MemoryDocValuesIterator returns 2 documents
|
||||
instead of 1. (Simon Willnauer)
|
||||
|
||||
Build
|
||||
|
||||
* LUCENE-6144: Upgrade Ivy to 2.4.0; 'ant ivy-bootstrap' now removes old Ivy
|
||||
|
|
|
@ -929,7 +929,7 @@ public class MemoryIndex {
|
|||
}
|
||||
|
||||
int docId() {
|
||||
return doc > 1 ? NumericDocValues.NO_MORE_DOCS : doc;
|
||||
return doc > 0 ? NumericDocValues.NO_MORE_DOCS : doc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.apache.lucene.index.SortedSetDocValues;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.search.CollectionStatistics;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.search.PhraseQuery;
|
||||
|
@ -274,6 +275,7 @@ public class TestMemoryIndex extends LuceneTestCase {
|
|||
NumericDocValues numericDocValues = leafReader.getNumericDocValues("numeric");
|
||||
assertEquals(0, numericDocValues.nextDoc());
|
||||
assertEquals(29L, numericDocValues.longValue());
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, numericDocValues.nextDoc());
|
||||
SortedNumericDocValues sortedNumericDocValues = leafReader.getSortedNumericDocValues("sorted_numeric");
|
||||
assertEquals(0, sortedNumericDocValues.nextDoc());
|
||||
assertEquals(5, sortedNumericDocValues.docValueCount());
|
||||
|
@ -282,14 +284,17 @@ public class TestMemoryIndex extends LuceneTestCase {
|
|||
assertEquals(32L, sortedNumericDocValues.nextValue());
|
||||
assertEquals(32L, sortedNumericDocValues.nextValue());
|
||||
assertEquals(33L, sortedNumericDocValues.nextValue());
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedNumericDocValues.nextDoc());
|
||||
BinaryDocValues binaryDocValues = leafReader.getBinaryDocValues("binary");
|
||||
assertEquals(0, binaryDocValues.nextDoc());
|
||||
assertEquals("a", binaryDocValues.binaryValue().utf8ToString());
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, binaryDocValues.nextDoc());
|
||||
SortedDocValues sortedDocValues = leafReader.getSortedDocValues("sorted");
|
||||
assertEquals(0, sortedDocValues.nextDoc());
|
||||
assertEquals("b", sortedDocValues.binaryValue().utf8ToString());
|
||||
assertEquals(0, sortedDocValues.ordValue());
|
||||
assertEquals("b", sortedDocValues.lookupOrd(0).utf8ToString());
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedDocValues.nextDoc());
|
||||
SortedSetDocValues sortedSetDocValues = leafReader.getSortedSetDocValues("sorted_set");
|
||||
assertEquals(3, sortedSetDocValues.getValueCount());
|
||||
assertEquals(0, sortedSetDocValues.nextDoc());
|
||||
|
@ -300,6 +305,7 @@ public class TestMemoryIndex extends LuceneTestCase {
|
|||
assertEquals("c", sortedSetDocValues.lookupOrd(0L).utf8ToString());
|
||||
assertEquals("d", sortedSetDocValues.lookupOrd(1L).utf8ToString());
|
||||
assertEquals("f", sortedSetDocValues.lookupOrd(2L).utf8ToString());
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sortedDocValues.nextDoc());
|
||||
}
|
||||
|
||||
public void testDocValues_resetIterator() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue