From 6ba2b5d579ee229664f430a9efdff0bd35dab8dd Mon Sep 17 00:00:00 2001 From: John Mazanec Date: Tue, 13 Dec 2022 10:06:16 -0800 Subject: [PATCH] Add model index to system index plugin (#630) Extends SystemIndexPlugin. Adds k-NN model system index plugin to SystemIndexPlugin list of system index descriptors. Signed-off-by: John Mazanec --- .../org/opensearch/knn/plugin/KNNPlugin.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/knn/plugin/KNNPlugin.java b/src/main/java/org/opensearch/knn/plugin/KNNPlugin.java index 670294802..4836c6c47 100644 --- a/src/main/java/org/opensearch/knn/plugin/KNNPlugin.java +++ b/src/main/java/org/opensearch/knn/plugin/KNNPlugin.java @@ -10,6 +10,7 @@ import org.opensearch.common.ParseField; import org.opensearch.index.codec.CodecServiceFactory; import org.opensearch.index.engine.EngineFactory; +import org.opensearch.indices.SystemIndexDescriptor; import org.opensearch.knn.index.KNNCircuitBreaker; import org.opensearch.knn.index.KNNClusterUtil; import org.opensearch.knn.index.query.KNNQueryBuilder; @@ -83,6 +84,7 @@ import org.opensearch.plugins.Plugin; import org.opensearch.plugins.ScriptPlugin; import org.opensearch.plugins.SearchPlugin; +import org.opensearch.plugins.SystemIndexPlugin; import org.opensearch.repositories.RepositoriesService; import org.opensearch.rest.RestController; import org.opensearch.rest.RestHandler; @@ -105,6 +107,7 @@ import static java.util.Collections.singletonList; import static org.opensearch.knn.common.KNNConstants.KNN_THREAD_POOL_PREFIX; +import static org.opensearch.knn.common.KNNConstants.MODEL_INDEX_NAME; import static org.opensearch.knn.common.KNNConstants.TRAIN_THREAD_POOL; /** @@ -137,7 +140,15 @@ * } * */ -public class KNNPlugin extends Plugin implements MapperPlugin, SearchPlugin, ActionPlugin, EnginePlugin, ScriptPlugin, ExtensiblePlugin { +public class KNNPlugin extends Plugin + implements + MapperPlugin, + SearchPlugin, + ActionPlugin, + EnginePlugin, + ScriptPlugin, + ExtensiblePlugin, + SystemIndexPlugin { public static final String LEGACY_KNN_BASE_URI = "/_opendistro/_knn"; public static final String KNN_BASE_URI = "/_plugins/_knn"; @@ -323,4 +334,8 @@ public List getNamedXContent() { return entries; } + @Override + public Collection getSystemIndexDescriptors(Settings settings) { + return ImmutableList.of(new SystemIndexDescriptor(MODEL_INDEX_NAME, "Index for storing models used for k-NN indices")); + } }