mirror of https://github.com/apache/lucene.git
LUCENE-7791: add tests for index sorting with sparse text fields and norms
This commit is contained in:
parent
0404e37357
commit
3316f47bcf
|
@ -2411,12 +2411,15 @@ public class TestIndexSorting extends LuceneTestCase {
|
||||||
Sort indexSort = new Sort(sortField);
|
Sort indexSort = new Sort(sortField);
|
||||||
iwc.setIndexSort(indexSort);
|
iwc.setIndexSort(indexSort);
|
||||||
IndexWriter w = new IndexWriter(dir, iwc);
|
IndexWriter w = new IndexWriter(dir, iwc);
|
||||||
|
Field textField = newTextField("sparse_text", "", Field.Store.NO);
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new NumericDocValuesField("dense_int", i));
|
doc.add(new NumericDocValuesField("dense_int", i));
|
||||||
if (i < 64) {
|
if (i < 64) {
|
||||||
doc.add(new NumericDocValuesField("sparse_int", i));
|
doc.add(new NumericDocValuesField("sparse_int", i));
|
||||||
doc.add(new BinaryDocValuesField("sparse_binary", new BytesRef(Integer.toString(i))));
|
doc.add(new BinaryDocValuesField("sparse_binary", new BytesRef(Integer.toString(i))));
|
||||||
|
textField.setStringValue("foo");
|
||||||
|
doc.add(textField);
|
||||||
}
|
}
|
||||||
w.addDocument(doc);
|
w.addDocument(doc);
|
||||||
}
|
}
|
||||||
|
@ -2429,6 +2432,7 @@ public class TestIndexSorting extends LuceneTestCase {
|
||||||
NumericDocValues denseValues = leafReader.getNumericDocValues("dense_int");
|
NumericDocValues denseValues = leafReader.getNumericDocValues("dense_int");
|
||||||
NumericDocValues sparseValues = leafReader.getNumericDocValues("sparse_int");
|
NumericDocValues sparseValues = leafReader.getNumericDocValues("sparse_int");
|
||||||
BinaryDocValues sparseBinaryValues = leafReader.getBinaryDocValues("sparse_binary");
|
BinaryDocValues sparseBinaryValues = leafReader.getBinaryDocValues("sparse_binary");
|
||||||
|
NumericDocValues normsValues = leafReader.getNormValues("sparse_text");
|
||||||
for(int docID = 0; docID < 128; docID++) {
|
for(int docID = 0; docID < 128; docID++) {
|
||||||
assertTrue(denseValues.advanceExact(docID));
|
assertTrue(denseValues.advanceExact(docID));
|
||||||
assertEquals(127-docID, (int) denseValues.longValue());
|
assertEquals(127-docID, (int) denseValues.longValue());
|
||||||
|
@ -2436,12 +2440,14 @@ public class TestIndexSorting extends LuceneTestCase {
|
||||||
assertTrue(denseValues.advanceExact(docID));
|
assertTrue(denseValues.advanceExact(docID));
|
||||||
assertTrue(sparseValues.advanceExact(docID));
|
assertTrue(sparseValues.advanceExact(docID));
|
||||||
assertTrue(sparseBinaryValues.advanceExact(docID));
|
assertTrue(sparseBinaryValues.advanceExact(docID));
|
||||||
assertEquals(docID, sparseValues.docID());
|
assertTrue(normsValues.advanceExact(docID));
|
||||||
|
assertEquals(124, normsValues.longValue());
|
||||||
assertEquals(127-docID, (int) sparseValues.longValue());
|
assertEquals(127-docID, (int) sparseValues.longValue());
|
||||||
assertEquals(new BytesRef(Integer.toString(127-docID)), sparseBinaryValues.binaryValue());
|
assertEquals(new BytesRef(Integer.toString(127-docID)), sparseBinaryValues.binaryValue());
|
||||||
} else {
|
} else {
|
||||||
assertFalse(sparseBinaryValues.advanceExact(docID));
|
assertFalse(sparseBinaryValues.advanceExact(docID));
|
||||||
assertFalse(sparseValues.advanceExact(docID));
|
assertFalse(sparseValues.advanceExact(docID));
|
||||||
|
assertFalse(normsValues.advanceExact(docID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IOUtils.close(r, w, dir);
|
IOUtils.close(r, w, dir);
|
||||||
|
|
Loading…
Reference in New Issue