Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

remove deprecated KnnVectorField use (#3121)

Christine Poerschkecc9a0f81b5a0
diff --git a/solr/core/src/java/org/apache/solr/schema/DenseVectorField.java b/solr/core/src/java/org/apache/solr/schema/DenseVectorField.java
index 4d528361dd4..773c1e6337d 100644
--- a/solr/core/src/java/org/apache/solr/schema/DenseVectorField.java
+++ b/solr/core/src/java/org/apache/solr/schema/DenseVectorField.java
@@ -52,8 +52,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Provides a field type to support Lucene's {@link org.apache.lucene.document.KnnVectorField}. See
- * {@link org.apache.lucene.search.KnnVectorQuery} for more details. It supports a fixed cardinality
+ * Provides a field type to support Lucene's {@link org.apache.lucene.document.KnnByteVectorField}
+ * and {@link org.apache.lucene.document.KnnFloatVectorField}. See {@link
+ * org.apache.lucene.search.KnnByteVectorQuery} and {@link
+ * org.apache.lucene.search.KnnFloatVectorQuery} for more details. It supports a fixed cardinality
* dimension for the vector and a fixed similarity function. The default similarity is
* EUCLIDEAN_HNSW (L2). The default algorithm is HNSW. For Lucene 9.1 e.g. See {@link
* org.apache.lucene.util.hnsw.HnswGraph} for more details about the implementation. <br>
diff --git a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
index 3dd77cc1155..80ecd512e1c 100644
--- a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
@@ -26,7 +26,6 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.KnnFloatVectorField;
-import org.apache.lucene.document.KnnVectorField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.tests.util.TestUtil;
@@ -352,8 +351,8 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
Document out = DocumentBuilder.toDocument(doc, core.getLatestSchema());
// from /solr/core/src/test-files/solr/collection1/conf/schema.xml
- KnnVectorField expectedIndexableField =
- new KnnVectorField(
+ KnnFloatVectorField expectedIndexableField =
+ new KnnFloatVectorField(
"vector", new float[] {1.1f, 2.1f, 3.1f, 4.1f}, VectorSimilarityFunction.COSINE);
assertThat(
@@ -383,8 +382,8 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
Document out = DocumentBuilder.toDocument(doc, core.getLatestSchema());
// from /solr/core/src/test-files/solr/collection1/conf/schema.xml
- KnnVectorField expectedDestination =
- new KnnVectorField(
+ KnnFloatVectorField expectedDestination =
+ new KnnFloatVectorField(
"vector2", new float[] {1.1f, 2.1f, 3.1f, 4.1f}, VectorSimilarityFunction.DOT_PRODUCT);
assertThat(
diff --git a/solr/core/src/test/org/apache/solr/update/DocumentBuilderVectorCatchAllCopyTest.java b/solr/core/src/test/org/apache/solr/update/DocumentBuilderVectorCatchAllCopyTest.java
index cda41e76e0b..aa3b5af772f 100644
--- a/solr/core/src/test/org/apache/solr/update/DocumentBuilderVectorCatchAllCopyTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DocumentBuilderVectorCatchAllCopyTest.java
@@ -24,7 +24,6 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.KnnFloatVectorField;
-import org.apache.lucene.document.KnnVectorField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.solr.SolrTestCaseJ4;
@@ -54,8 +53,8 @@ public class DocumentBuilderVectorCatchAllCopyTest extends SolrTestCaseJ4 {
Document out = DocumentBuilder.toDocument(doc, core.getLatestSchema());
// from /solr/core/src/test-files/solr/collection1/conf/schema.xml
- KnnVectorField expectedDestination =
- new KnnVectorField(
+ KnnFloatVectorField expectedDestination =
+ new KnnFloatVectorField(
"vector2", new float[] {1.1f, 2.1f, 3.1f, 4.1f}, VectorSimilarityFunction.DOT_PRODUCT);
assertThat(