stefanvodita commented on code in PR #12548:
URL: https://github.com/apache/lucene/pull/12548#discussion_r1341952008
##
lucene/core/src/test/org/apache/lucene/search/TestVectorSimilarityValuesSource.java:
##
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.search;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.KnnByteVectorField;
+import org.apache.lucene.document.KnnFloatVectorField;
+import org.apache.lucene.document.SortedDocValuesField;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.VectorSimilarityFunction;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.index.RandomIndexWriter;
+import org.apache.lucene.tests.util.LuceneTestCase;
+import org.apache.lucene.util.BytesRef;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class TestVectorSimilarityValuesSource extends LuceneTestCase {
+ private static Directory dir;
+ private static Analyzer analyzer;
+ private static IndexReader reader;
+ private static IndexSearcher searcher;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+dir = newDirectory();
+analyzer = new MockAnalyzer(random());
+IndexWriterConfig iwConfig = newIndexWriterConfig(analyzer);
+iwConfig.setMergePolicy(newLogMergePolicy());
+RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConfig);
+
+Document document = new Document();
+document.add(new StringField("id", "1", Field.Store.NO));
+document.add(new SortedDocValuesField("id", new BytesRef("1")));
+document.add(new KnnFloatVectorField("knnFloatField1", new float[] {1.f,
2.f, 3.f}));
+document.add(
+new KnnFloatVectorField(
+"knnFloatField2",
+new float[] {2.2f, -3.2f, -3.1f},
+VectorSimilarityFunction.DOT_PRODUCT));
+document.add(
+new KnnFloatVectorField(
+"knnFloatField3", new float[] {4.5f, 10.3f, -7.f},
VectorSimilarityFunction.COSINE));
+document.add(
+new KnnFloatVectorField(
+"knnFloatField4",
+new float[] {-1.3f, 1.0f, 1.0f},
+VectorSimilarityFunction.MAXIMUM_INNER_PRODUCT));
+document.add(new KnnFloatVectorField("knnFloatField5", new float[] {-6.7f,
-1.0f, -0.9f}));
+document.add(new KnnByteVectorField("knnByteField1", new byte[] {106, 80,
127}));
+document.add(
+new KnnByteVectorField(
+"knnByteField2", new byte[] {4, 2, 3},
VectorSimilarityFunction.DOT_PRODUCT));
+document.add(
+new KnnByteVectorField(
+"knnByteField3", new byte[] {-121, -64, -1},
VectorSimilarityFunction.COSINE));
+document.add(
+new KnnByteVectorField(
+"knnByteField4",
+new byte[] {-127, 127, 127},
+VectorSimilarityFunction.MAXIMUM_INNER_PRODUCT));
+iw.addDocument(document);
+
+Document document2 = new Document();
+document2.add(new StringField("id", "2", Field.Store.NO));
+document2.add(new SortedDocValuesField("id", new BytesRef("2")));
+document2.add(new KnnFloatVectorField("knnFloatField1", new float[] {1.f,
2.f, 3.f}));
+document2.add(
+new KnnFloatVectorField(
+"knnFloatField2",
+new float[] {-5.2f, 8.7f, 3.1f},
+VectorSimilarityFunction.DOT_PRODUCT));
+document2.add(
+new KnnFloatVectorField(
+"knnFloatField3", new float[] {0.2f, -3.2f, 3.1f},
VectorSimilarityFunction.COSINE));
+document2.add(new KnnFloatVectorField("knnFloatField5", new float[] {2.f,
13.2f, 9.1f}));
+document2.add(new KnnByteVectorField("knnByteField1", new byte[] {1, -2,
-30}));
+document2.add(
+new KnnByteVectorField(
+"knnByteField2", new byte[] {40, 21, 3},
VectorSimilarityFunction.DOT_PRODUCT));
+document2.add(
+new KnnByteVectorField(
+"knnByteField3", new by