Github user jpountz commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/516#discussion_r239408003
--- Diff:
lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
---
@@ -1587,6 +1590,76 @@ public void testDocValuesUpdates() throws Exception {
writer.close();
dir.close();
}
+
+ public void testSoftDeletes() throws Exception {
+ Path oldIndexDir = createTempDir("dvupdates");
+ TestUtil.unzip(getDataInputStream(dvUpdatesIndex), oldIndexDir);
+ Directory dir = newFSDirectory(oldIndexDir);
+ verifyUsesDefaultCodec(dir, dvUpdatesIndex);
+ IndexWriterConfig conf = new IndexWriterConfig(new
MockAnalyzer(random())).setSoftDeletesField("__soft_delete");
+ IndexWriter writer = new IndexWriter(dir, conf);
+ int maxDoc = writer.maxDoc();
+ writer.updateDocValues(new Term("id", "1"),new
NumericDocValuesField("__soft_delete", 1));
+
+ if (random().nextBoolean()) {
+ writer.commit();
+ }
+ writer.forceMerge(1);
+ writer.commit();
+ assertEquals(maxDoc-1, writer.maxDoc());
+ writer.close();
+ dir.close();
+ }
+
+ public void testDocValuesUpdatesWithNewField() throws Exception {
+ Path oldIndexDir = createTempDir("dvupdates");
+ TestUtil.unzip(getDataInputStream(dvUpdatesIndex), oldIndexDir);
+ Directory dir = newFSDirectory(oldIndexDir);
+ verifyUsesDefaultCodec(dir, dvUpdatesIndex);
+
+ // update fields and verify index
+ IndexWriterConfig conf = new IndexWriterConfig(new
MockAnalyzer(random()));
+ IndexWriter writer = new IndexWriter(dir, conf);
+ // introduce a new field that we later update
+ writer.addDocument(Arrays.asList(new StringField("id", "" +
Integer.MAX_VALUE, Field.Store.NO),
+ new NumericDocValuesField("new_numeric", 1),
+ new BinaryDocValuesField("new_binary", toBytes(1))));
+ writer.updateNumericDocValue(new Term("id", "1"), "new_numeric", 1);
+ writer.updateBinaryDocValue(new Term("id", "1"), "new_binary",
toBytes(1));
+
+ writer.commit();
+ Callable assertDV = () -> {
--- End diff --
s/Callable/Runnable/ since you don't care about the return value/
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]