Introduce NoOpIndexReader to handle missing indexes without errors (#2113)

We stumbled upon errors accessing index from plugins which were not yet initialized. To prevent this errors we use our own No-Op IndexReader for missing indices.
This commit is contained in:
Eduard Heimbuch
2022-09-06 10:06:17 +02:00
committed by GitHub
parent 1d2e0cefb6
commit 6f2be13197
4 changed files with 192 additions and 1 deletions

View File

@@ -173,6 +173,14 @@ class IndexManagerTest {
}
}
@Test
void shouldOpenNoOpIndexReaderForMissingIndex() throws IOException {
open(Songs.class, "idx-for-read");
try (IndexReader reader = indexManager.openForRead(searchableType, "idx-for-read")) {
assertThat(reader).isInstanceOf(NoOpIndexReader.class);
}
}
private void addDoc(IndexWriter writer, String name) throws IOException {
Document doc = new Document();
doc.add(new TextField("hitchhiker", name, Field.Store.YES));