forked from elastic/elasticsearch
-
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.
Execute ingest node pipeline before creating the index (elastic#39607)
Prior to this commit (and after 6.5.0), if an ingest node changes the _index in a pipeline, the original target index would be created. For daily indexes this could create an extra, empty index per day. This commit changes the TransportBulkAction to execute the ingest node pipeline before attempting to create the index. This ensures that the only index created is the original or one set by the ingest node pipeline. This was the execution order prior to 6.5.0 (elastic#32786). The execution order was changed in 6.5 to better support default pipelines. Specifically the execution order was changed to be able to read the settings from the index meta data. This commit also includes a change in logic such that if the target index does not exist when ingest node pipeline runs, it will now pull the default pipeline (if one exists) from the settings of the best matched of the index template. Relates elastic#32786 Relates elastic#32758 Closes elastic#36545
- Loading branch information
1 parent
54d41af
commit a815da6
Showing
5 changed files
with
252 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,4 +91,4 @@ teardown: | |
get: | ||
index: test | ||
id: 3 | ||
- match: { found: false } | ||
|
119 changes: 119 additions & 0 deletions
119
...es/ingest-common/src/test/resources/rest-api-spec/test/ingest/230_change_target_index.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,119 @@ | ||
--- | ||
teardown: | ||
- do: | ||
ingest.delete_pipeline: | ||
id: "retarget" | ||
ignore: 404 | ||
|
||
- do: | ||
indices.delete: | ||
index: foo | ||
|
||
--- | ||
"Test Change Target Index with Explicit Pipeline": | ||
|
||
- do: | ||
ingest.put_pipeline: | ||
id: "retarget" | ||
body: > | ||
{ | ||
"processors": [ | ||
{ | ||
"set" : { | ||
"field" : "_index", | ||
"value" : "foo" | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
# no indices | ||
- do: | ||
cat.indices: {} | ||
|
||
- match: | ||
$body: | | ||
/^$/ | ||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
pipeline: "retarget" | ||
body: { | ||
a: true | ||
} | ||
|
||
- do: | ||
get: | ||
index: foo | ||
id: 1 | ||
- match: { _source.a: true } | ||
|
||
# only the foo index | ||
- do: | ||
cat.indices: | ||
h: i | ||
|
||
- match: | ||
$body: | | ||
/^foo\n$/ | ||
--- | ||
"Test Change Target Index with Default Pipeline": | ||
|
||
- do: | ||
indices.put_template: | ||
name: index_template | ||
body: | ||
index_patterns: test | ||
settings: | ||
default_pipeline: "retarget" | ||
|
||
- do: | ||
ingest.put_pipeline: | ||
id: "retarget" | ||
body: > | ||
{ | ||
"processors": [ | ||
{ | ||
"set" : { | ||
"field" : "_index", | ||
"value" : "foo" | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
# no indices | ||
- do: | ||
cat.indices: {} | ||
|
||
- match: | ||
$body: | | ||
/^$/ | ||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: { | ||
a: true | ||
} | ||
|
||
- do: | ||
get: | ||
index: foo | ||
id: 1 | ||
- match: { _source.a: true } | ||
|
||
# only the foo index | ||
- do: | ||
cat.indices: | ||
h: i | ||
|
||
- match: | ||
$body: | | ||
/^foo\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
Oops, something went wrong.