From 4f7ae019500f8fd6848d70f511d9ead9e78a4d26 Mon Sep 17 00:00:00 2001 From: Naveen Tatikonda Date: Mon, 22 Jul 2024 18:06:24 -0500 Subject: [PATCH] Set default encoder as encoder flat Signed-off-by: Naveen Tatikonda --- .../java/org/opensearch/knn/index/util/Lucene.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/knn/index/util/Lucene.java b/src/main/java/org/opensearch/knn/index/util/Lucene.java index e68020ed93..caf4200cbd 100644 --- a/src/main/java/org/opensearch/knn/index/util/Lucene.java +++ b/src/main/java/org/opensearch/knn/index/util/Lucene.java @@ -7,12 +7,15 @@ import com.google.common.collect.ImmutableMap; import org.apache.lucene.util.Version; +import org.opensearch.knn.common.KNNConstants; import org.opensearch.knn.index.KNNMethod; import org.opensearch.knn.index.KNNSettings; import org.opensearch.knn.index.MethodComponent; +import org.opensearch.knn.index.MethodComponentContext; import org.opensearch.knn.index.Parameter; import org.opensearch.knn.index.SpaceType; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -37,6 +40,11 @@ public class Lucene extends JVMLibrary { Map> distanceTransform; private static final List LUCENE_SQ_BITS_SUPPORTED = List.of(7); + private final static MethodComponentContext ENCODER_DEFAULT = new MethodComponentContext( + KNNConstants.ENCODER_FLAT, + Collections.emptyMap() + ); + private final static Map HNSW_ENCODERS = ImmutableMap.of( ENCODER_SQ, MethodComponent.Builder.builder(ENCODER_SQ) @@ -73,7 +81,7 @@ public class Lucene extends JVMLibrary { ) .addParameter( METHOD_ENCODER_PARAMETER, - new Parameter.MethodComponentContextParameter(METHOD_ENCODER_PARAMETER, null, HNSW_ENCODERS) + new Parameter.MethodComponentContextParameter(METHOD_ENCODER_PARAMETER, ENCODER_DEFAULT, HNSW_ENCODERS) ) .build() ).addSpaces(SpaceType.UNDEFINED, SpaceType.L2, SpaceType.COSINESIMIL, SpaceType.INNER_PRODUCT).build()