-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add the ability to require an ingest pipeline #46847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
82eb8d0
Add the ability to require an ingest pipeline
jasontedor c636e93
Add some REST tests
jasontedor 5ddab06
Fix double processing
jasontedor 3d618a7
Add assertion
jasontedor e044c1c
Fix NPE in tests
jasontedor 01416c1
Always mark as resolved
jasontedor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
175 changes: 175 additions & 0 deletions
175
modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/240_required_pipeline.yml
This file contains hidden or 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,175 @@ | ||
--- | ||
teardown: | ||
- do: | ||
ingest.delete_pipeline: | ||
id: "my_pipeline" | ||
ignore: 404 | ||
|
||
--- | ||
"Test index with required pipeline": | ||
- do: | ||
ingest.put_pipeline: | ||
id: "my_pipeline" | ||
body: > | ||
{ | ||
"description": "_description", | ||
"processors": [ | ||
{ | ||
"bytes" : { | ||
"field" : "bytes_source_field", | ||
"target_field" : "bytes_target_field" | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
# required pipeline via index | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
required_pipeline: "my_pipeline" | ||
aliases: | ||
test_alias: {} | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: {bytes_source_field: "1kb"} | ||
|
||
- do: | ||
get: | ||
index: test | ||
id: 1 | ||
- match: { _source.bytes_source_field: "1kb" } | ||
- match: { _source.bytes_target_field: 1024 } | ||
# required pipeline via alias | ||
- do: | ||
index: | ||
index: test_alias | ||
id: 2 | ||
body: {bytes_source_field: "1kb"} | ||
|
||
- do: | ||
get: | ||
index: test | ||
id: 2 | ||
- match: { _source.bytes_source_field: "1kb" } | ||
- match: { _source.bytes_target_field: 1024 } | ||
# required pipeline via upsert | ||
- do: | ||
update: | ||
index: test | ||
id: 3 | ||
body: | ||
script: | ||
source: "ctx._source.ran_script = true" | ||
lang: "painless" | ||
upsert: { "bytes_source_field":"1kb" } | ||
- do: | ||
get: | ||
index: test | ||
id: 3 | ||
- match: { _source.bytes_source_field: "1kb" } | ||
- match: { _source.bytes_target_field: 1024 } | ||
# required pipeline via scripted upsert | ||
- do: | ||
update: | ||
index: test | ||
id: 4 | ||
body: | ||
script: | ||
source: "ctx._source.bytes_source_field = '1kb'" | ||
lang: "painless" | ||
upsert : {} | ||
scripted_upsert: true | ||
- do: | ||
get: | ||
index: test | ||
id: 4 | ||
- match: { _source.bytes_source_field: "1kb" } | ||
- match: { _source.bytes_target_field: 1024 } | ||
# required pipeline via doc_as_upsert | ||
- do: | ||
update: | ||
index: test | ||
id: 5 | ||
body: | ||
doc: { "bytes_source_field":"1kb" } | ||
doc_as_upsert: true | ||
- do: | ||
get: | ||
index: test | ||
id: 5 | ||
- match: { _source.bytes_source_field: "1kb" } | ||
- match: { _source.bytes_target_field: 1024 } | ||
# required pipeline via bulk upsert | ||
# note - bulk scripted upsert's execute the pipeline before the script, so any data referenced by the pipeline | ||
# needs to be in the upsert, not the script | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | | ||
{"update":{"_id":"6","_index":"test"}} | ||
{"script":"ctx._source.ran_script = true","upsert":{"bytes_source_field":"1kb"}} | ||
{"update":{"_id":"7","_index":"test"}} | ||
{"doc":{"bytes_source_field":"2kb"}, "doc_as_upsert":true} | ||
{"update":{"_id":"8","_index":"test"}} | ||
{"script": "ctx._source.ran_script = true","upsert":{"bytes_source_field":"3kb"}, "scripted_upsert" : true} | ||
{"update":{"_id":"6_alias","_index":"test_alias"}} | ||
{"script":"ctx._source.ran_script = true","upsert":{"bytes_source_field":"1kb"}} | ||
{"update":{"_id":"7_alias","_index":"test_alias"}} | ||
{"doc":{"bytes_source_field":"2kb"}, "doc_as_upsert":true} | ||
{"update":{"_id":"8_alias","_index":"test_alias"}} | ||
{"script": "ctx._source.ran_script = true","upsert":{"bytes_source_field":"3kb"}, "scripted_upsert" : true} | ||
|
||
- do: | ||
mget: | ||
body: | ||
docs: | ||
- { _index: "test", _id: "6" } | ||
- { _index: "test", _id: "7" } | ||
- { _index: "test", _id: "8" } | ||
- { _index: "test", _id: "6_alias" } | ||
- { _index: "test", _id: "7_alias" } | ||
- { _index: "test", _id: "8_alias" } | ||
- match: { docs.0._index: "test" } | ||
- match: { docs.0._id: "6" } | ||
- match: { docs.0._source.bytes_source_field: "1kb" } | ||
- match: { docs.0._source.bytes_target_field: 1024 } | ||
- is_false: docs.0._source.ran_script | ||
- match: { docs.1._index: "test" } | ||
- match: { docs.1._id: "7" } | ||
- match: { docs.1._source.bytes_source_field: "2kb" } | ||
- match: { docs.1._source.bytes_target_field: 2048 } | ||
- match: { docs.2._index: "test" } | ||
- match: { docs.2._id: "8" } | ||
- match: { docs.2._source.bytes_source_field: "3kb" } | ||
- match: { docs.2._source.bytes_target_field: 3072 } | ||
- match: { docs.2._source.ran_script: true } | ||
- match: { docs.3._index: "test" } | ||
- match: { docs.3._id: "6_alias" } | ||
- match: { docs.3._source.bytes_source_field: "1kb" } | ||
- match: { docs.3._source.bytes_target_field: 1024 } | ||
- is_false: docs.3._source.ran_script | ||
- match: { docs.4._index: "test" } | ||
- match: { docs.4._id: "7_alias" } | ||
- match: { docs.4._source.bytes_source_field: "2kb" } | ||
- match: { docs.4._source.bytes_target_field: 2048 } | ||
- match: { docs.5._index: "test" } | ||
- match: { docs.5._id: "8_alias" } | ||
- match: { docs.5._source.bytes_source_field: "3kb" } | ||
- match: { docs.5._source.bytes_target_field: 3072 } | ||
- match: { docs.5._source.ran_script: true } | ||
|
||
# bad request, request pipeline can not be specified | ||
- do: | ||
catch: /illegal_argument_exception.*request pipeline \[pipeline\] can not override required pipeline \[my_pipeline\]/ | ||
index: | ||
index: test | ||
id: 9 | ||
pipeline: "pipeline" | ||
body: {bytes_source_field: "1kb"} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.