Skip to content

Commit 9f28ef8

Browse files
Add false_allow_templates as a dynamic mapping option (opensearch-project#18825)
* Starting work, untested Update tests Tests Tests Cleanup Tested, cleanup Cleanup Signed-off-by: Bruce Hong <[email protected]> * Rebase Signed-off-by: Bruce Hong <[email protected]> * Fix rest-api-spec:spotlessApply Signed-off-by: Bruce Hong <[email protected]> * Run :server:spotlessApply Signed-off-by: Bruce Hong <[email protected]> * Improve test coverage Signed-off-by: Bruce Hong <[email protected]> * Spotless apply Signed-off-by: Bruce Hong <[email protected]> * DRY-er Signed-off-by: Bruce Hong <[email protected]> * Spotless check Signed-off-by: Bruce Hong <[email protected]> * Comments Signed-off-by: Bruce Hong <[email protected]> * Comments Signed-off-by: Bruce Hong <[email protected]> --------- Signed-off-by: Bruce Hong <[email protected]> Signed-off-by: gaobinlong <[email protected]> Co-authored-by: gaobinlong <[email protected]>
1 parent 8f310f5 commit 9f28ef8

File tree

8 files changed

+938
-19
lines changed

8 files changed

+938
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
### Added
88
- Expand fetch phase profiling to support inner hits and top hits aggregation phases ([##18936](https://github.com/opensearch-project/OpenSearch/pull/18936))
99
- Add temporal routing processors for time-based document routing ([#18920](https://github.com/opensearch-project/OpenSearch/issues/18920))
10+
- The dynamic mapping parameter supports false_allow_templates ([#18825](https://github.com/opensearch-project/OpenSearch/pull/18825))
1011

1112

1213
### Changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
"Index documents with setting dynamic parameter to false_allow_templates in the mapping of the index":
3+
- skip:
4+
version: " - 3.2.99"
5+
reason: "introduced in 3.3.0"
6+
7+
- do:
8+
indices.create:
9+
index: test_1
10+
body:
11+
mappings:
12+
dynamic: false_allow_templates
13+
dynamic_templates: [
14+
{
15+
dates: {
16+
"match": "date_*",
17+
"match_mapping_type": "date",
18+
"mapping": {
19+
"type": "date"
20+
}
21+
}
22+
},
23+
{
24+
strings: {
25+
"match": "stringField*",
26+
"match_mapping_type": "string",
27+
"mapping": {
28+
"type": "keyword"
29+
}
30+
}
31+
},
32+
{
33+
object: {
34+
"match": "objectField*",
35+
"match_mapping_type": "object",
36+
"mapping": {
37+
"type": "object",
38+
"properties": {
39+
"bar1": {
40+
"type": "keyword"
41+
},
42+
"bar2": {
43+
"type": "text"
44+
}
45+
}
46+
}
47+
}
48+
},
49+
{
50+
boolean: {
51+
"match": "booleanField*",
52+
"match_mapping_type": "boolean",
53+
"mapping": {
54+
"type": "boolean"
55+
}
56+
}
57+
},
58+
{
59+
long: {
60+
"match": "longField*",
61+
"match_mapping_type": "long",
62+
"mapping": {
63+
"type": "long"
64+
}
65+
}
66+
},
67+
{
68+
double: {
69+
"match": "doubleField*",
70+
"match_mapping_type": "double",
71+
"mapping": {
72+
"type": "double"
73+
}
74+
}
75+
},
76+
{
77+
float: {
78+
"match": "floatField*",
79+
"match_mapping_type": "float",
80+
"mapping": {
81+
"type": "float"
82+
}
83+
}
84+
},
85+
{
86+
integer: {
87+
"match": "integerField*",
88+
"match_mapping_type": "integer",
89+
"mapping": {
90+
"type": "integer"
91+
}
92+
}
93+
},
94+
{
95+
array: {
96+
"match": "arrayField*",
97+
"mapping": {
98+
"type": "keyword"
99+
}
100+
}
101+
}
102+
]
103+
properties:
104+
url:
105+
type: keyword
106+
107+
- do:
108+
index:
109+
index: test_1
110+
id: 1
111+
body: {
112+
url: "https://example.com",
113+
date_timestamp: "2024-06-25T05:11:51.243Z",
114+
stringField: "bar",
115+
objectField: {
116+
bar1: "bar1",
117+
bar2: "bar2"
118+
},
119+
booleanField: true,
120+
longField: 123456789,
121+
doubleField: 123.456,
122+
floatField: 123.45,
123+
integerField: 12345,
124+
arrayField: ["item1", "item2", "item3"],
125+
author: "John Doe"
126+
}
127+
128+
- do:
129+
get:
130+
index: test_1
131+
id: 1
132+
- match:
133+
_source:
134+
url: "https://example.com"
135+
date_timestamp: "2024-06-25T05:11:51.243Z"
136+
stringField: "bar"
137+
objectField:
138+
bar1: "bar1"
139+
bar2: "bar2"
140+
booleanField: true
141+
longField: 123456789
142+
doubleField: 123.456
143+
floatField: 123.45
144+
integerField: 12345
145+
arrayField: ["item1", "item2", "item3"]
146+
author: "John Doe"
147+
148+
- do:
149+
indices.get_mapping:
150+
index: test_1
151+
152+
- match: {test_1.mappings.dynamic: false_allow_templates}
153+
- match: {test_1.mappings.properties.url.type: keyword}
154+
- match: {test_1.mappings.properties.date_timestamp.type: date}
155+
- match: {test_1.mappings.properties.stringField.type: keyword}
156+
- match: {test_1.mappings.properties.objectField.properties.bar1.type: keyword}
157+
- match: {test_1.mappings.properties.objectField.properties.bar2.type: text}
158+
- match: {test_1.mappings.properties.booleanField.type: boolean}
159+
- match: {test_1.mappings.properties.longField.type: long}
160+
- match: {test_1.mappings.properties.doubleField.type: double}
161+
- match: {test_1.mappings.properties.floatField.type: float}
162+
- match: {test_1.mappings.properties.integerField.type: integer}
163+
- match: {test_1.mappings.properties.arrayField.type: keyword}
164+
- match: {test_1.mappings.properties.author: null}
165+
- length: {test_1.mappings.properties: 11}

rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,34 @@ setup:
190190

191191
- match: {test_index1.mappings.dynamic: strict_allow_templates}
192192
- match: {test_index1.mappings.properties.test1.type: text}
193+
194+
---
195+
"post a mapping with setting dynamic to false_allow_templates":
196+
- skip:
197+
version: " - 3.2.99"
198+
reason: "introduced in 3.3.0"
199+
- do:
200+
indices.put_mapping:
201+
index: test_index1
202+
body:
203+
dynamic: false_allow_templates
204+
dynamic_templates: [
205+
{
206+
strings: {
207+
"match": "foo*",
208+
"match_mapping_type": "string",
209+
"mapping": {
210+
"type": "keyword"
211+
}
212+
}
213+
}
214+
]
215+
properties:
216+
test1:
217+
type: text
218+
219+
- do:
220+
indices.get_mapping: {}
221+
222+
- match: {test_index1.mappings.dynamic: false_allow_templates}
223+
- match: {test_index1.mappings.properties.test1.type: text}

0 commit comments

Comments
 (0)