mirror of https://github.com/apache/lucene.git
LUCENE-5239: don't delete same term for the wrong field
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1525851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
951e056b33
commit
cf06226cb8
|
@ -47,6 +47,8 @@ final class FreqProxTermsWriter extends TermsHashConsumer {
|
|||
Terms terms = fields.terms(lastField);
|
||||
if (terms != null) {
|
||||
termsEnum = terms.iterator(termsEnum);
|
||||
} else {
|
||||
termsEnum = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2281,4 +2281,27 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
evilWriter.close();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
// LUCENE-5239
|
||||
public void testDeleteSameTermAcrossFields() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
IndexWriter w = new IndexWriter(dir, iwc);
|
||||
Document doc = new Document();
|
||||
doc.add(new TextField("a", "foo", Field.Store.NO));
|
||||
w.addDocument(doc);
|
||||
|
||||
// Should not delete the document; with LUCENE-5239 the
|
||||
// "foo" from the 2nd delete term would incorrectly
|
||||
// match field a's "foo":
|
||||
w.deleteDocuments(new Term("a", "xxx"));
|
||||
w.deleteDocuments(new Term("b", "foo"));
|
||||
IndexReader r = w.getReader();
|
||||
w.close();
|
||||
|
||||
// Make sure document was not (incorrectly) deleted:
|
||||
assertEquals(1, r.numDocs());
|
||||
r.close();
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue