LUCENE-5189: add testcase

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1523525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-09-16 01:56:46 +00:00
parent a97e0b69df
commit b502fdb597
1 changed files with 33 additions and 0 deletions

View File

@ -447,6 +447,39 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
dir.close(); dir.close();
} }
public void testUnsetAllValues() throws Exception {
assumeTrue("codec does not support docsWithField", defaultCodecSupportsDocsWithField());
Directory dir = newDirectory();
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
IndexWriter writer = new IndexWriter(dir, conf);
for (int i = 0; i < 2; i++) {
Document doc = new Document();
doc.add(new StringField("id", "doc", Store.NO));
doc.add(new NumericDocValuesField("ndv", 5));
writer.addDocument(doc);
}
writer.commit();
// unset the value of 'doc'
writer.updateNumericDocValue(new Term("id", "doc"), "ndv", null);
writer.close();
final DirectoryReader reader = DirectoryReader.open(dir);
AtomicReader r = reader.leaves().get(0).reader();
NumericDocValues ndv = r.getNumericDocValues("ndv");
for (int i = 0; i < r.maxDoc(); i++) {
assertEquals(0, ndv.get(i));
}
Bits docsWithField = r.getDocsWithField("ndv");
assertFalse(docsWithField.get(0));
assertFalse(docsWithField.get(1));
reader.close();
dir.close();
}
@Test @Test
public void testUpdateNonDocValueField() throws Exception { public void testUpdateNonDocValueField() throws Exception {
// we don't support adding new fields or updating existing non-numeric-dv // we don't support adding new fields or updating existing non-numeric-dv