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) (opensearch-project#14737) * The dynamic mapping parameter supports strict_allow_templates * Modify change log * Modify skip version in yml test file * Refactor some code * Keep the old methods * change public to private * Optimize some code * Do not override toString method for Dynamic * Optimize some code and modify the changelog --------- (cherry picked from commit 6b8b3ef) Signed-off-by: Gao Binlong <gbinlong@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: kkewwei <kkewwei@163.com>
- Loading branch information
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.15.99" | ||
reason: "introduced in 2.16.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.