fix TestKnnGraph test failure if it gets SimpleText

This test reaches into lucene90 internals, fails with classcastexception
if it happens to get simpletext.
This commit is contained in:
Robert Muir 2021-02-28 14:43:36 -05:00
parent 1fff174690
commit 96eb043131
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
1 changed files with 3 additions and 1 deletions

View File

@ -213,8 +213,10 @@ public class TestKnnGraph extends LuceneTestCase {
public void testSearch() throws Exception {
// We can't use dot product here since the vectors are laid out on a grid, not a sphere.
searchStrategy = SearchStrategy.EUCLIDEAN_HNSW;
IndexWriterConfig config = newIndexWriterConfig();
config.setCodec(Codec.forName("Lucene90")); // test is not compatible with simpletext
try (Directory dir = newDirectory();
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig())) {
IndexWriter iw = new IndexWriter(dir, config)) {
// Add a document for every cartesian point in an NxN square so we can
// easily know which are the nearest neighbors to every point. Insert by iterating
// using a prime number that is not a divisor of N*N so that we will hit each point once,