diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java index eefae00350b9..6d2dd19ae36b 100644 --- a/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBackwardsCompatibility.java @@ -109,6 +109,7 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.WildcardQuery; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; @@ -2268,6 +2269,25 @@ public void testFailOpenOldIndex() throws IOException { } } + // #12895: test on a carefully crafted 9.8.0 index (from a small contiguous subset of wikibigall unique terms) that shows the read-time + // #exception of IntersectTermsEnum (used by WildcardQuery) + public void testWildcardQueryExceptions990() throws IOException { + Path path = createTempDir("12895"); + + String name = "index.12895.9.8.0.zip"; + InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream(name); + assertNotNull("missing zip file to reproduce #12895", resource); + TestUtil.unzip(resource, path); + + try (Directory dir = newFSDirectory(path); + DirectoryReader reader = DirectoryReader.open(dir)) { + IndexSearcher searcher = new IndexSearcher(reader); + + searcher.count(new WildcardQuery(new Term("field", "*qx*"))); + } + } + + @Nightly public void testReadNMinusTwoCommit() throws IOException { for (String name : binarySupportedNames) { diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/index.12895.9.8.0.zip b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/index.12895.9.8.0.zip new file mode 100644 index 000000000000..867afc7a7e3e Binary files /dev/null and b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/index.12895.9.8.0.zip differ