forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
strict_allow_templates
dynamic mapping option (opensearch-proje…
…ct#14555) * The dynamic mapping parameter supports strict_allow_templates Signed-off-by: Gao Binlong <[email protected]> * Modify change log Signed-off-by: Gao Binlong <[email protected]> * Modify skip version in yml test file Signed-off-by: Gao Binlong <[email protected]> * Refactor some code Signed-off-by: Gao Binlong <[email protected]> * Keep the old methods Signed-off-by: Gao Binlong <[email protected]> * change public to private Signed-off-by: Gao Binlong <[email protected]> * Optimize some code Signed-off-by: Gao Binlong <[email protected]> * Do not override toString method for Dynamic Signed-off-by: Gao Binlong <[email protected]> * Optimize some code and modify the changelog Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]>
- Loading branch information
1 parent
79e2777
commit 2dd1dca
Showing
8 changed files
with
688 additions
and
57 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
155 changes: 155 additions & 0 deletions
155
rest-api-spec/src/main/resources/rest-api-spec/test/index/110_strict_allow_templates.yml
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,155 @@ | ||
--- | ||
"Index documents with setting dynamic parameter to strict_allow_templates in the mapping of the index": | ||
- skip: | ||
version: " - 2.99.99" | ||
reason: "introduced in 3.0.0" | ||
|
||
- do: | ||
indices.create: | ||
index: test_1 | ||
body: | ||
mappings: | ||
dynamic: strict_allow_templates | ||
dynamic_templates: [ | ||
{ | ||
strings: { | ||
"match": "stringField*", | ||
"match_mapping_type": "string", | ||
"mapping": { | ||
"type": "keyword" | ||
} | ||
} | ||
}, | ||
{ | ||
object: { | ||
"match": "objectField*", | ||
"match_mapping_type": "object", | ||
"mapping": { | ||
"type": "object", | ||
"properties": { | ||
"bar1": { | ||
"type": "keyword" | ||
}, | ||
"bar2": { | ||
"type": "text" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
boolean: { | ||
"match": "booleanField*", | ||
"match_mapping_type": "boolean", | ||
"mapping": { | ||
"type": "boolean" | ||
} | ||
} | ||
}, | ||
{ | ||
double: { | ||
"match": "doubleField*", | ||
"match_mapping_type": "double", | ||
"mapping": { | ||
"type": "double" | ||
} | ||
} | ||
}, | ||
{ | ||
long: { | ||
"match": "longField*", | ||
"match_mapping_type": "long", | ||
"mapping": { | ||
"type": "long" | ||
} | ||
} | ||
}, | ||
{ | ||
array: { | ||
"match": "arrayField*", | ||
"mapping": { | ||
"type": "keyword" | ||
} | ||
} | ||
}, | ||
{ | ||
date: { | ||
"match": "dateField*", | ||
"match_mapping_type": "date", | ||
"mapping": { | ||
"type": "date" | ||
} | ||
} | ||
} | ||
] | ||
properties: | ||
test1: | ||
type: text | ||
|
||
- do: | ||
catch: /mapping set to strict_allow_templates, dynamic introduction of \[test2\] within \[\_doc\] is not allowed/ | ||
index: | ||
index: test_1 | ||
id: 1 | ||
body: { | ||
stringField: bar, | ||
objectField: { | ||
bar1: "bar1", | ||
bar2: "bar2" | ||
}, | ||
test1: test1, | ||
test2: test2 | ||
} | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
id: 1 | ||
body: { | ||
stringField: bar, | ||
objectField: { | ||
bar1: "bar1", | ||
bar2: "bar2" | ||
}, | ||
booleanField: true, | ||
doubleField: 1.0, | ||
longField: 100, | ||
arrayField: ["1","2"], | ||
dateField: "2024-06-25T05:11:51.243Z", | ||
test1: test1 | ||
} | ||
|
||
- do: | ||
get: | ||
index: test_1 | ||
id: 1 | ||
- match: { _source: { | ||
stringField: bar, | ||
objectField: { | ||
bar1: "bar1", | ||
bar2: "bar2" | ||
}, | ||
booleanField: true, | ||
doubleField: 1.0, | ||
longField: 100, | ||
arrayField: [ "1","2" ], | ||
dateField: "2024-06-25T05:11:51.243Z", | ||
test1: test1 | ||
} | ||
} | ||
|
||
- do: | ||
indices.get_mapping: { | ||
index: test_1 | ||
} | ||
|
||
- match: {test_1.mappings.dynamic: strict_allow_templates} | ||
- match: {test_1.mappings.properties.stringField.type: keyword} | ||
- match: {test_1.mappings.properties.objectField.properties.bar1.type: keyword} | ||
- match: {test_1.mappings.properties.objectField.properties.bar2.type: text} | ||
- match: {test_1.mappings.properties.booleanField.type: boolean} | ||
- match: {test_1.mappings.properties.doubleField.type: double} | ||
- match: {test_1.mappings.properties.longField.type: long} | ||
- match: {test_1.mappings.properties.arrayField.type: keyword} | ||
- match: {test_1.mappings.properties.dateField.type: date} | ||
- match: {test_1.mappings.properties.test1.type: text} |
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
Oops, something went wrong.