uschindler commented on code in PR #13200:
URL: https://github.com/apache/lucene/pull/13200#discussion_r1552040639


##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/word2vec/Word2VecSynonymProvider.java:
##########
@@ -40,8 +40,8 @@
  */
 public class Word2VecSynonymProvider {
 
-  private static final VectorSimilarityFunction SIMILARITY_FUNCTION =
-      VectorSimilarityFunction.DOT_PRODUCT;
+  private static final VectorSimilarity SIMILARITY_FUNCTION =
+      VectorSimilarity.DotProductSimilarity.INSTANCE;

Review Comment:
   Shouldn't this be renamed?



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -196,7 +196,18 @@ public FieldInfos read(
           }
           final int vectorDimension = input.readVInt();
           final VectorEncoding vectorEncoding = getVectorEncoding(input, 
input.readByte());
-          final VectorSimilarityFunction vectorDistFunc = getDistFunc(input, 
input.readByte());
+          final VectorSimilarity vectorDistFunc;
+          if (format < FORMAT_PLUGGABLE_SIMILARITY) {
+            final byte distanceFunctionOrdinal = input.readByte();
+            if (distanceFunctionOrdinal < 0
+                || distanceFunctionOrdinal >= 
VectorSimilarity.LEGACY_VALUE_LENGTH) {
+              throw new IllegalArgumentException("invalid distance function: " 
+ i);

Review Comment:
   I think this should be a CorruptIndexEx. Same below. At least the old code 
throwed this Exception.



##########
lucene/core/src/java/module-info.java:
##########
@@ -61,6 +61,8 @@
   // Open certain packages for the test framework (ram usage tester).
   opens org.apache.lucene.document to
       org.apache.lucene.test_framework;
+  opens org.apache.lucene.codecs to

Review Comment:
   Why is this needed?



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene94/Lucene94FieldInfosFormat.java:
##########
@@ -409,7 +385,11 @@ public void write(
         }
         output.writeVInt(fi.getVectorDimension());
         output.writeByte((byte) fi.getVectorEncoding().ordinal());
-        output.writeByte(distFuncToOrd(fi.getVectorSimilarityFunction()));
+        if (fi.getVectorSimilarity() == null) {

Review Comment:
   Maybe:
   
   ```java
   Optional.ofNullable(fi.getVectorSimilarity())
    
    .orElse(VectorSimilarity.EuclideanDistanceSimilarity.INSTANCE)
     .getName()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to