--- teardown: - do: ingest.delete_pipeline: id: "my_pipeline" ignore: 404 --- "Test index with final 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 } # final pipeline via index - do: indices.create: index: test body: settings: index: final_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 } # final 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 } # final 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 } # final 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 } # final 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 } # final 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 }