-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yaliang Wu <ylwu@amazon.com> (cherry picked from commit b9036b1) Co-authored-by: Yaliang Wu <ylwu@amazon.com>
- Loading branch information
1 parent
a80aac4
commit 858cd84
Showing
26 changed files
with
514 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
common/src/main/java/org/opensearch/ml/common/CommonValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common; | ||
|
||
public class CommonValue { | ||
|
||
public static Integer NO_SCHEMA_VERSION = 0; | ||
public static final String USER = "user"; | ||
public static final String META = "_meta"; | ||
public static final String SCHEMA_VERSION_FIELD = "schema_version"; | ||
|
||
public static final String ML_MODEL_INDEX = ".plugins-ml-model"; | ||
public static final String ML_TASK_INDEX = ".plugins-ml-task"; | ||
public static final Integer ML_MODEL_INDEX_SCHEMA_VERSION = 1; | ||
public static final Integer ML_TASK_INDEX_SCHEMA_VERSION = 1; | ||
public static final String USER_FIELD_MAPPING = " \"" | ||
+ CommonValue.USER | ||
+ "\": {\n" | ||
+ " \"type\": \"nested\",\n" | ||
+ " \"properties\": {\n" | ||
+ " \"name\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\", \"ignore_above\":256}}},\n" | ||
+ " \"backend_roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n" | ||
+ " \"roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n" | ||
+ " \"custom_attribute_names\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}}\n" | ||
+ " }\n" | ||
+ " }\n"; | ||
public static final String ML_MODEL_INDEX_MAPPING = "{\n" | ||
+ " \"_meta\": {\"schema_version\": " | ||
+ ML_MODEL_INDEX_SCHEMA_VERSION | ||
+ "},\n" | ||
+ " \"properties\": {\n" | ||
+ " \"" | ||
+ MLModel.ALGORITHM_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLModel.MODEL_NAME_FIELD | ||
+ "\" : {\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\n" | ||
+ " \"" | ||
+ MLModel.MODEL_VERSION_FIELD | ||
+ "\" : {\"type\": \"long\"},\n" | ||
+ " \"" | ||
+ MLModel.MODEL_CONTENT_FIELD | ||
+ "\" : {\"type\": \"binary\"},\n" | ||
+ USER_FIELD_MAPPING | ||
+ " }\n" | ||
+ "}"; | ||
|
||
public static final String ML_TASK_INDEX_MAPPING = "{\n" | ||
+ " \"_meta\": {\"schema_version\": " | ||
+ ML_TASK_INDEX_SCHEMA_VERSION | ||
+ "},\n" | ||
+ " \"properties\": {\n" | ||
+ " \"" | ||
+ MLTask.MODEL_ID_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.TASK_TYPE_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.FUNCTION_NAME_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.STATE_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.INPUT_TYPE_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.PROGRESS_FIELD | ||
+ "\": {\"type\": \"float\"},\n" | ||
+ " \"" | ||
+ MLTask.OUTPUT_INDEX_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.WORKER_NODE_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ MLTask.CREATE_TIME_FIELD | ||
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n" | ||
+ " \"" | ||
+ MLTask.LAST_UPDATE_TIME_FIELD | ||
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n" | ||
+ " \"" | ||
+ MLTask.ERROR_FIELD | ||
+ "\": {\"type\": \"text\"},\n" | ||
+ " \"" | ||
+ MLTask.IS_ASYNC_TASK_FIELD | ||
+ "\" : {\"type\" : \"boolean\"}, \n" | ||
+ USER_FIELD_MAPPING | ||
+ " }\n" | ||
+ "}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
plugin/src/main/java/org/opensearch/ml/indices/MLIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.indices; | ||
|
||
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX; | ||
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX_MAPPING; | ||
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX_SCHEMA_VERSION; | ||
import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX; | ||
import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX_MAPPING; | ||
import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX_SCHEMA_VERSION; | ||
|
||
public enum MLIndex { | ||
MODEL(ML_MODEL_INDEX, false, ML_MODEL_INDEX_MAPPING, ML_MODEL_INDEX_SCHEMA_VERSION), | ||
TASK(ML_TASK_INDEX, false, ML_TASK_INDEX_MAPPING, ML_TASK_INDEX_SCHEMA_VERSION); | ||
|
||
private final String indexName; | ||
// whether we use an alias for the index | ||
private final boolean alias; | ||
private final String mapping; | ||
private final Integer version; | ||
|
||
MLIndex(String name, boolean alias, String mapping, Integer version) { | ||
this.indexName = name; | ||
this.alias = alias; | ||
this.mapping = mapping; | ||
this.version = version; | ||
} | ||
|
||
public String getIndexName() { | ||
return indexName; | ||
} | ||
|
||
public boolean isAlias() { | ||
return alias; | ||
} | ||
|
||
public String getMapping() { | ||
return mapping; | ||
} | ||
|
||
public Integer getVersion() { | ||
return version; | ||
} | ||
} |
Oops, something went wrong.