Skip to content

Commit

Permalink
Set default encoder as encoder flat
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen Tatikonda <[email protected]>
  • Loading branch information
naveentatikonda committed Jul 22, 2024
1 parent 5ff5db4 commit 4f7ae01
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/org/opensearch/knn/index/util/Lucene.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +40,11 @@ public class Lucene extends JVMLibrary {
Map<SpaceType, Function<Float, Float>> distanceTransform;
private static final List<Integer> LUCENE_SQ_BITS_SUPPORTED = List.of(7);

private final static MethodComponentContext ENCODER_DEFAULT = new MethodComponentContext(
KNNConstants.ENCODER_FLAT,
Collections.emptyMap()
);

private final static Map<String, MethodComponent> HNSW_ENCODERS = ImmutableMap.of(
ENCODER_SQ,
MethodComponent.Builder.builder(ENCODER_SQ)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4f7ae01

Please sign in to comment.