SimpleText knn vectors; fix searchExhaustively and suppress a byte format test case (#11725)

This commit is contained in:
Michael Sokolov 2022-08-29 11:49:52 -04:00 committed by GitHub
parent 29f94b0404
commit 61ef031f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -41,7 +41,6 @@ import org.apache.lucene.store.BufferedChecksumIndexInput;
import org.apache.lucene.store.ChecksumIndexInput; import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder; import org.apache.lucene.util.BytesRefBuilder;
@ -187,8 +186,9 @@ public class SimpleTextKnnVectorsReader extends KnnVectorsReader {
@Override @Override
public TopDocs searchExhaustively( public TopDocs searchExhaustively(
String field, float[] target, int k, DocIdSetIterator acceptDocs) throws IOException { String field, float[] target, int k, DocIdSetIterator acceptDocs) throws IOException {
int numDocs = (int) acceptDocs.cost(); FieldInfo info = readState.fieldInfos.fieldInfo(field);
return search(field, target, k, BitSet.of(acceptDocs, numDocs), Integer.MAX_VALUE); VectorSimilarityFunction vectorSimilarity = info.getVectorSimilarityFunction();
return exhaustiveSearch(getVectorValues(field), acceptDocs, vectorSimilarity, target, k);
} }
@Override @Override

View File

@ -20,6 +20,7 @@ import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriter;
@ -513,6 +514,9 @@ public class TestField extends LuceneTestCase {
} }
public void testKnnVectorField() throws Exception { public void testKnnVectorField() throws Exception {
if (Codec.getDefault().getName().equals("SimpleText")) {
return;
}
try (Directory dir = newDirectory(); try (Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig())) { IndexWriter w = new IndexWriter(dir, newIndexWriterConfig())) {
Document doc = new Document(); Document doc = new Document();