diff --git a/src/main/java/org/opensearch/knn/common/KNNConstants.java b/src/main/java/org/opensearch/knn/common/KNNConstants.java index cae212977..bf07bc15f 100644 --- a/src/main/java/org/opensearch/knn/common/KNNConstants.java +++ b/src/main/java/org/opensearch/knn/common/KNNConstants.java @@ -83,7 +83,7 @@ public class KNNConstants { public static final String METHOD_PARAMETER_NPROBES = "nprobes"; public static final String ENCODER_FLAT = "flat"; public static final String ENCODER_PQ = "pq"; - public static final String ENCODER_PARAMETER_PQ_CODE_COUNT = "code_count"; + public static final String ENCODER_PARAMETER_PQ_M = "m"; public static final String ENCODER_PARAMETER_PQ_CODE_SIZE = "code_size"; public static final String FAISS_HNSW_DESCRIPTION = "HNSW"; public static final String FAISS_IVF_DESCRIPTION = "IVF"; diff --git a/src/main/java/org/opensearch/knn/index/KNNSettings.java b/src/main/java/org/opensearch/knn/index/KNNSettings.java index e1930f722..a1fec201d 100644 --- a/src/main/java/org/opensearch/knn/index/KNNSettings.java +++ b/src/main/java/org/opensearch/knn/index/KNNSettings.java @@ -90,9 +90,9 @@ public class KNNSettings { public static final String KNN_PLUGIN_ENABLED = "knn.plugin.enabled"; public static final String KNN_CIRCUIT_BREAKER_UNSET_PERCENTAGE = "knn.circuit_breaker.unset.percentage"; public static final String KNN_INDEX = "index.knn"; - public static final String MODEL_INDEX_NUMBER_OF_SHARDS = "knn.model_index_number_of_shards"; - public static final String MODEL_INDEX_NUMBER_OF_REPLICAS = "knn.model_index_number_of_replicas"; - public static final String MODEL_CACHE_SIZE_LIMIT = "knn.model_cache.size.limit"; + public static final String MODEL_INDEX_NUMBER_OF_SHARDS = "knn.model.index.number_of_shards"; + public static final String MODEL_INDEX_NUMBER_OF_REPLICAS = "knn.model.index.number_of_replicas"; + public static final String MODEL_CACHE_SIZE_LIMIT = "knn.model.cache.size.limit"; /** * Default setting values diff --git a/src/main/java/org/opensearch/knn/index/util/KNNLibrary.java b/src/main/java/org/opensearch/knn/index/util/KNNLibrary.java index 7cd81eb54..90e9cafc2 100644 --- a/src/main/java/org/opensearch/knn/index/util/KNNLibrary.java +++ b/src/main/java/org/opensearch/knn/index/util/KNNLibrary.java @@ -29,7 +29,7 @@ import java.util.function.Function; import static org.opensearch.knn.common.KNNConstants.BYTES_PER_KILOBYTES; -import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT; +import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M; import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT_DEFAULT; import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT_LIMIT; import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE; @@ -331,8 +331,8 @@ class Faiss extends NativeLibrary { MethodAsMapBuilder.builder(KNNConstants.FAISS_FLAT_DESCRIPTION, methodComponent, methodComponentContext).build())).build(), KNNConstants.ENCODER_PQ, MethodComponent.Builder.builder(KNNConstants.ENCODER_PQ) - .addParameter(ENCODER_PARAMETER_PQ_CODE_COUNT, - new Parameter.IntegerParameter(ENCODER_PARAMETER_PQ_CODE_COUNT, + .addParameter(ENCODER_PARAMETER_PQ_M, + new Parameter.IntegerParameter(ENCODER_PARAMETER_PQ_M, ENCODER_PARAMETER_PQ_CODE_COUNT_DEFAULT, v -> v > 0 && v < ENCODER_PARAMETER_PQ_CODE_COUNT_LIMIT)) .addParameter(ENCODER_PARAMETER_PQ_CODE_SIZE, @@ -342,7 +342,7 @@ class Faiss extends NativeLibrary { .setRequiresTraining(true) .setMapGenerator(((methodComponent, methodComponentContext) -> MethodAsMapBuilder.builder(FAISS_PQ_DESCRIPTION, methodComponent, methodComponentContext) - .addParameter(ENCODER_PARAMETER_PQ_CODE_COUNT, "", "") + .addParameter(ENCODER_PARAMETER_PQ_M, "", "") .addParameter(ENCODER_PARAMETER_PQ_CODE_SIZE, "x", "") .build())) .setOverheadInKBEstimator((methodComponent, methodComponentContext, dimension) -> { diff --git a/src/test/java/org/opensearch/knn/jni/JNIServiceTests.java b/src/test/java/org/opensearch/knn/jni/JNIServiceTests.java index 553e450d2..786a49d3d 100644 --- a/src/test/java/org/opensearch/knn/jni/JNIServiceTests.java +++ b/src/test/java/org/opensearch/knn/jni/JNIServiceTests.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; -import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT; +import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M; import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE; import static org.opensearch.knn.common.KNNConstants.ENCODER_PQ; import static org.opensearch.knn.common.KNNConstants.FAISS_NAME; @@ -559,7 +559,7 @@ public void testCreateIndexFromTemplate() throws IOException { METHOD_PARAMETER_NLIST, 16, METHOD_ENCODER_PARAMETER, new MethodComponentContext(ENCODER_PQ, ImmutableMap.of( - ENCODER_PARAMETER_PQ_CODE_COUNT, 16, + ENCODER_PARAMETER_PQ_M, 16, ENCODER_PARAMETER_PQ_CODE_SIZE, 8 ))))); diff --git a/src/test/java/org/opensearch/knn/plugin/action/RestTrainModelHandlerIT.java b/src/test/java/org/opensearch/knn/plugin/action/RestTrainModelHandlerIT.java index 061527aae..5f51aa2ac 100644 --- a/src/test/java/org/opensearch/knn/plugin/action/RestTrainModelHandlerIT.java +++ b/src/test/java/org/opensearch/knn/plugin/action/RestTrainModelHandlerIT.java @@ -22,14 +22,13 @@ import java.io.IOException; import java.util.Map; -import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_COUNT; import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_CODE_SIZE; +import static org.opensearch.knn.common.KNNConstants.ENCODER_PARAMETER_PQ_M; import static org.opensearch.knn.common.KNNConstants.KNN_ENGINE; import static org.opensearch.knn.common.KNNConstants.METHOD_ENCODER_PARAMETER; import static org.opensearch.knn.common.KNNConstants.METHOD_PARAMETER_NLIST; import static org.opensearch.knn.common.KNNConstants.METHOD_PARAMETER_SPACE_TYPE; import static org.opensearch.knn.common.KNNConstants.MODEL_ID; -import static org.opensearch.knn.common.KNNConstants.MODEL_STATE; import static org.opensearch.knn.common.KNNConstants.NAME; import static org.opensearch.knn.common.KNNConstants.PARAMETERS; @@ -237,7 +236,7 @@ public void testTrainModel_success_withId() throws IOException, InterruptedExcep "name":"pq", "parameters":{ "code_size":2, - "code_count": 2 + "m": 2 } } } @@ -254,7 +253,7 @@ public void testTrainModel_success_withId() throws IOException, InterruptedExcep .field(NAME, "pq") .startObject(PARAMETERS) .field(ENCODER_PARAMETER_PQ_CODE_SIZE, 2) - .field(ENCODER_PARAMETER_PQ_CODE_COUNT, 2) + .field(ENCODER_PARAMETER_PQ_M, 2) .endObject() .endObject() .endObject() @@ -311,7 +310,7 @@ public void testTrainModel_success_noId() throws IOException, InterruptedExcepti "name":"pq", "parameters":{ "code_size":2, - "code_count": 2 + "m": 2 } } } @@ -328,7 +327,7 @@ public void testTrainModel_success_noId() throws IOException, InterruptedExcepti .field(NAME, "pq") .startObject(PARAMETERS) .field(ENCODER_PARAMETER_PQ_CODE_SIZE, 2) - .field(ENCODER_PARAMETER_PQ_CODE_COUNT, 2) + .field(ENCODER_PARAMETER_PQ_M, 2) .endObject() .endObject() .endObject()