1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
// This file is autogenerated, DO NOT EDIT
// ingest/processors/script.asciidoc:48
[source, python]
----
resp = client.ingest.simulate(
pipeline={
"processors": [
{
"script": {
"description": "Extract 'tags' from 'env' field",
"lang": "painless",
"source": "\n String[] envSplit = ctx['env'].splitOnToken(params['delimiter']);\n ArrayList tags = new ArrayList();\n tags.add(envSplit[params['position']].trim());\n ctx['tags'] = tags;\n ",
"params": {
"delimiter": "-",
"position": 1
}
}
}
]
},
docs=[
{
"_source": {
"env": "es01-prod"
}
}
],
)
print(resp)
----
|