mirror of https://github.com/apache/lucene.git
LUCENE-8243: fix IndexWriter.addIndexes(Directory[]) to properly preserve index file names for updated doc values fields
This commit is contained in:
parent
bd8fe72426
commit
99364584ff
|
@ -129,6 +129,10 @@ Bug Fixes
|
|||
* LUCENE-8236: Filter duplicated points when creating GeoPath shapes to
|
||||
avoid creation of bogus planes. (Ignacio Vera)
|
||||
|
||||
* LUCENE-8243: IndexWriter.addIndexes(Directory[]) did not properly preserve
|
||||
index file names for updated doc values fields (Simon Willnauer,
|
||||
Michael McCandless)
|
||||
|
||||
Other
|
||||
|
||||
* LUCENE-8228: removed obsolete IndexDeletionPolicy clone() requirements from
|
||||
|
|
|
@ -3207,8 +3207,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
|||
info.info.getDiagnostics(), info.info.getId(), info.info.getAttributes(), info.info.getIndexSort());
|
||||
SegmentCommitInfo newInfoPerCommit = new SegmentCommitInfo(newInfo, info.getDelCount(), info.getDelGen(),
|
||||
info.getFieldInfosGen(), info.getDocValuesGen());
|
||||
|
||||
newInfo.setFiles(info.files());
|
||||
|
||||
newInfo.setFiles(info.info.files());
|
||||
newInfoPerCommit.setFieldInfosFiles(info.getFieldInfosFiles());
|
||||
newInfoPerCommit.setDocValuesUpdatesFiles(info.getDocValuesUpdatesFiles());
|
||||
|
||||
boolean success = false;
|
||||
|
||||
|
@ -3228,7 +3230,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
|||
}
|
||||
}
|
||||
|
||||
assert copiedFiles.equals(newInfoPerCommit.files());
|
||||
assert copiedFiles.equals(newInfoPerCommit.files()): "copiedFiles=" + copiedFiles + " vs " + newInfoPerCommit.files();
|
||||
|
||||
return newInfoPerCommit;
|
||||
}
|
||||
|
@ -3569,6 +3571,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
|||
return seqNo;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
private final void finishCommit() throws IOException {
|
||||
|
||||
boolean commitCompleted = false;
|
||||
|
|
|
@ -1332,4 +1332,85 @@ public class TestAddIndexes extends LuceneTestCase {
|
|||
assertEquals("cannot change index sort from <int: \"foo\"> to <string: \"foo\">", message);
|
||||
IOUtils.close(r1, dir1, w2, dir2);
|
||||
}
|
||||
|
||||
public void testAddIndexesDVUpdateSameSegmentName() throws Exception {
|
||||
Directory dir1 = newDirectory();
|
||||
IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
IndexWriter w1 = new IndexWriter(dir1, iwc1);
|
||||
Document doc = new Document();
|
||||
doc.add(new StringField("id", "1", Field.Store.YES));
|
||||
doc.add(new StringField("version", "1", Field.Store.YES));
|
||||
doc.add(new NumericDocValuesField("soft_delete", 1));
|
||||
w1.addDocument(doc);
|
||||
w1.flush();
|
||||
|
||||
w1.updateDocValues(new Term("id", "1"), new NumericDocValuesField("soft_delete", 1));
|
||||
w1.commit();
|
||||
w1.close();
|
||||
|
||||
IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
Directory dir2 = newDirectory();
|
||||
IndexWriter w2 = new IndexWriter(dir2, iwc2);
|
||||
w2.addIndexes(dir1);
|
||||
w2.commit();
|
||||
w2.close();
|
||||
|
||||
if (VERBOSE) {
|
||||
System.out.println("\nTEST: now open w3");
|
||||
}
|
||||
IndexWriterConfig iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
if (VERBOSE) {
|
||||
iwc3.setInfoStream(System.out);
|
||||
}
|
||||
IndexWriter w3 = new IndexWriter(dir2, iwc3);
|
||||
w3.close();
|
||||
|
||||
iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
w3 = new IndexWriter(dir2, iwc3);
|
||||
w3.close();
|
||||
dir1.close();
|
||||
dir2.close();
|
||||
}
|
||||
|
||||
public void testAddIndexesDVUpdateNewSegmentName() throws Exception {
|
||||
Directory dir1 = newDirectory();
|
||||
IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
IndexWriter w1 = new IndexWriter(dir1, iwc1);
|
||||
Document doc = new Document();
|
||||
doc.add(new StringField("id", "1", Field.Store.YES));
|
||||
doc.add(new StringField("version", "1", Field.Store.YES));
|
||||
doc.add(new NumericDocValuesField("soft_delete", 1));
|
||||
w1.addDocument(doc);
|
||||
w1.flush();
|
||||
|
||||
w1.updateDocValues(new Term("id", "1"), new NumericDocValuesField("soft_delete", 1));
|
||||
w1.commit();
|
||||
w1.close();
|
||||
|
||||
IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
Directory dir2 = newDirectory();
|
||||
IndexWriter w2 = new IndexWriter(dir2, iwc2);
|
||||
w2.addDocument(new Document());
|
||||
w2.commit();
|
||||
|
||||
w2.addIndexes(dir1);
|
||||
w2.commit();
|
||||
w2.close();
|
||||
|
||||
if (VERBOSE) {
|
||||
System.out.println("\nTEST: now open w3");
|
||||
}
|
||||
IndexWriterConfig iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
if (VERBOSE) {
|
||||
iwc3.setInfoStream(System.out);
|
||||
}
|
||||
IndexWriter w3 = new IndexWriter(dir2, iwc3);
|
||||
w3.close();
|
||||
|
||||
iwc3 = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
w3 = new IndexWriter(dir2, iwc3);
|
||||
w3.close();
|
||||
dir1.close();
|
||||
dir2.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue