From 8926872132f8e664d3a886e19814e8cc014f8250 Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Wed, 17 Apr 2024 13:25:42 -0700 Subject: [PATCH] Update name with default Signed-off-by: Junqiu Lei --- .../opensearch/knn/common/KNNConstants.java | 2 +- .../knn/index/query/RNNQueryFactory.java | 22 +++++++++---------- .../knn/index/query/KNNQueryBuilderTests.java | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/opensearch/knn/common/KNNConstants.java b/src/main/java/org/opensearch/knn/common/KNNConstants.java index ef5b5abc2..594f7d63a 100644 --- a/src/main/java/org/opensearch/knn/common/KNNConstants.java +++ b/src/main/java/org/opensearch/knn/common/KNNConstants.java @@ -134,5 +134,5 @@ public class KNNConstants { // https://github.com/opensearch-project/k-NN/issues/1049#issuecomment-1694741092 public static int MAX_DISTANCE_COMPUTATIONS = 2048000; - public static float LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO = 0.95f; + public static float DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO = 0.95f; } diff --git a/src/main/java/org/opensearch/knn/index/query/RNNQueryFactory.java b/src/main/java/org/opensearch/knn/index/query/RNNQueryFactory.java index eca370b52..2818f5d6a 100644 --- a/src/main/java/org/opensearch/knn/index/query/RNNQueryFactory.java +++ b/src/main/java/org/opensearch/knn/index/query/RNNQueryFactory.java @@ -5,7 +5,7 @@ package org.opensearch.knn.index.query; -import static org.opensearch.knn.common.KNNConstants.LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO; +import static org.opensearch.knn.common.KNNConstants.DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO; import static org.opensearch.knn.common.KNNConstants.VECTOR_DATA_TYPE_FIELD; import static org.opensearch.knn.index.VectorDataType.SUPPORTED_VECTOR_DATA_TYPES; @@ -120,11 +120,11 @@ private static Query getFloatVectorSimilarityQuery( final Query filterQuery ) { return new FloatVectorSimilarityQuery( - fieldName, - floatVector, - LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity, - resultSimilarity, - filterQuery + fieldName, + floatVector, + DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity, + resultSimilarity, + filterQuery ); } @@ -139,11 +139,11 @@ private static Query getByteVectorSimilarityQuery( final Query filterQuery ) { return new ByteVectorSimilarityQuery( - fieldName, - byteVector, - LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity, - resultSimilarity, - filterQuery + fieldName, + byteVector, + DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity, + resultSimilarity, + filterQuery ); } } diff --git a/src/test/java/org/opensearch/knn/index/query/KNNQueryBuilderTests.java b/src/test/java/org/opensearch/knn/index/query/KNNQueryBuilderTests.java index 76aa9158a..a0784d73a 100644 --- a/src/test/java/org/opensearch/knn/index/query/KNNQueryBuilderTests.java +++ b/src/test/java/org/opensearch/knn/index/query/KNNQueryBuilderTests.java @@ -52,7 +52,7 @@ import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.opensearch.knn.common.KNNConstants.LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO; +import static org.opensearch.knn.common.KNNConstants.DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO; import static org.opensearch.knn.common.KNNConstants.METHOD_HNSW; import static org.opensearch.knn.index.KNNClusterTestUtils.mockClusterService; import static org.opensearch.knn.index.util.KNNEngine.ENGINES_SUPPORTING_RADIAL_SEARCH; @@ -398,7 +398,7 @@ public void testDoToQuery_whenNormal_whenDoRadiusSearch_whenDistanceThreshold_th float resultSimilarity = KNNEngine.LUCENE.distanceToRadialThreshold(MAX_DISTANCE, SpaceType.L2); assertTrue(query.toString().contains("resultSimilarity=" + resultSimilarity)); - assertTrue(query.toString().contains("traversalSimilarity=" + LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity)); + assertTrue(query.toString().contains("traversalSimilarity=" + DEFAULT_LUCENE_RADIAL_SEARCH_TRAVERSAL_SIMILARITY_RATIO * resultSimilarity)); } public void testDoToQuery_whenNormal_whenDoRadiusSearch_whenScoreThreshold_thenSucceed() {