-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose dynamic_templates parameter in Ingest (#71716)
This change exposes the newly introduced parameter `dynamic_templates` in ingest. This parameter can be set by a set processor or a script processor. Relates #69948
- Loading branch information
Showing
8 changed files
with
234 additions
and
2 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
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
150 changes: 150 additions & 0 deletions
150
...th-all-dependencies/src/test/resources/rest-api-spec/test/ingest/70_dynamic_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,150 @@ | ||
--- | ||
"Dynamic templates": | ||
- do: | ||
indices.create: | ||
index: test_index | ||
body: | ||
mappings: | ||
dynamic_templates: | ||
- location: | ||
mapping: | ||
type: geo_point | ||
|
||
- do: | ||
ingest.put_pipeline: | ||
id: "my_set_pipeline" | ||
body: > | ||
{ | ||
"description": "Use location dynamic template for home_address and work_address", | ||
"processors": [ | ||
{ | ||
"set" : { | ||
"field": "_dynamic_templates", | ||
"value": { | ||
"home_address": "location", | ||
"work_address": "location" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
ingest.put_pipeline: | ||
id: "my_script_pipeline" | ||
body: > | ||
{ | ||
"description": "Use location dynamic template for home_address and work_address", | ||
"processors": [ | ||
{ | ||
"script" : { | ||
"source": "ctx._dynamic_templates = [params.f1: params.type, params.f2: params.type]", | ||
"params": { | ||
"f1": "home_address", | ||
"f2": "work_address", | ||
"type": "location" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_index | ||
_id: id_1 | ||
pipeline: my_set_pipeline | ||
- { "home_address": [ -71.34, 41.12 ]} | ||
- index: | ||
_index: test_index | ||
_id: id_2 | ||
pipeline: my_script_pipeline | ||
- { "work_address": "41.12,-71.34"} | ||
- match: { errors: false } | ||
- match: { items.0.index.result: created } | ||
- match: { items.1.index.result: created } | ||
|
||
- do: | ||
index: | ||
index: test_index | ||
id: id_3 | ||
body: { "home_address": [ -71.34, 41.12 ]} | ||
refresh: true | ||
pipeline: my_script_pipeline | ||
|
||
- do: | ||
index: | ||
index: test_index | ||
id: id_4 | ||
body: { "work_address": [ -71.34, 41.12 ]} | ||
refresh: true | ||
pipeline: my_set_pipeline | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
geo_bounding_box: | ||
home_address: | ||
top_left: | ||
lat: 42 | ||
lon: -72 | ||
bottom_right: | ||
lat: 40 | ||
lon: -74 | ||
- match: { hits.total.value: 2 } | ||
- match: { hits.hits.0._id: id_1 } | ||
- match: { hits.hits.1._id: id_3 } | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
geo_bounding_box: | ||
work_address: | ||
top_left: | ||
lat: 42 | ||
lon: -72 | ||
bottom_right: | ||
lat: 40 | ||
lon: -74 | ||
- match: { hits.total.value: 2 } | ||
- match: { hits.hits.0._id: id_2 } | ||
- match: { hits.hits.1._id: id_4 } | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_index | ||
_id: id_5 | ||
pipeline: my_set_pipeline | ||
dynamic_templates: | ||
school_address: location | ||
- { "school_address": [ -71.34, 41.12 ]} | ||
- match: { errors: false } | ||
- match: { items.0.index.result: created } | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
geo_bounding_box: | ||
school_address: | ||
top_left: | ||
lat: 42 | ||
lon: -72 | ||
bottom_right: | ||
lat: 40 | ||
lon: -74 | ||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: id_5 } |
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