use of org.apache.lucene.util.IOSupplier in project OpenSearch by opensearch-project.
the class FsRepositoryTests method deleteRandomDoc.
private void deleteRandomDoc(Directory directory) throws IOException {
try (IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(random(), new MockAnalyzer(random())).setCodec(TestUtil.getDefaultCodec()).setMergePolicy(new FilterMergePolicy(NoMergePolicy.INSTANCE) {
@Override
public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
return true;
}
}))) {
final int numDocs = writer.getDocStats().numDocs;
writer.deleteDocuments(new Term("id", "" + randomIntBetween(0, writer.getDocStats().numDocs - 1)));
writer.commit();
assertEquals(writer.getDocStats().numDocs, numDocs - 1);
}
}
Aggregations