Created
June 19, 2019 23:51
-
-
Save haganbt/e79fde19aa5db172eec32197e9445dfe to your computer and use it in GitHub Desktop.
Elasticsearch ingest pipeline pushing data to another index
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
GET _cat/indices | |
# Create a pipeline that pushes the data to "index2" | |
PUT _ingest/pipeline/test | |
{ | |
"description" : "Push data to index2", | |
"processors": [ | |
{ | |
"script": { | |
"source": """ | |
ctx._index = 'index2'; | |
ctx._type = '_doc'; | |
ctx.field_foo_times_bar = (ctx.foo * ctx.bar) | |
""" | |
} | |
} | |
] | |
} | |
# Post to "index1" as normal and use the pipeline | |
PUT index1/_doc/1?pipeline=test | |
{ | |
"foo": 10, | |
"bar": 10 | |
} | |
# Default record in index1 | |
GET index1/_doc/1 | |
# Modified record in index2 | |
GET index2/_doc/1 | |
# Test a pipeline | |
POST _ingest/pipeline/_simulate | |
{ | |
"pipeline": { | |
"description" : "Demo", | |
"processors": [ | |
{ | |
"script": { | |
"source": """ | |
ctx.field_foo_times_bar = (ctx.foo * ctx.bar) | |
""" | |
} | |
} | |
] | |
}, | |
"docs": [ | |
{ | |
"_source": { | |
"foo": 10, | |
"bar": 10 | |
} | |
} | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment