Document using stored scripts for ingest (#58783)

This documents using stored scripts for complex conditionals in indest.
This commit is contained in:
Nik Everett 2020-07-01 13:35:13 -04:00
parent f63cbad629
commit 326cce624b

View File

@ -403,7 +403,7 @@ support new line characters. However, Kibana's console supports
a triple quote syntax to help with writing and debugging
scripts like these.
[source,js]
[source,console]
--------------------------------------------------
PUT _ingest/pipeline/not_prod_dropper
{
@ -426,9 +426,44 @@ PUT _ingest/pipeline/not_prod_dropper
]
}
--------------------------------------------------
// NOTCONSOLE
// TEST[continued]
or it can be built with a stored script:
[source,console]
--------------------------------------------------
PUT _scripts/not_prod
{
"script": {
"lang": "painless",
"source": """
Collection tags = ctx.tags;
if(tags != null){
for (String tag : tags) {
if (tag.toLowerCase().contains('prod')) {
return false;
}
}
}
return true;
"""
}
}
PUT _ingest/pipeline/not_prod_dropper
{
"processors": [
{
"drop": {
"if": { "id": "not_prod" }
}
}
]
}
--------------------------------------------------
// TEST[continued]
Either way, you can run it with:
[source,console]
--------------------------------------------------
POST test/_doc/1?pipeline=not_prod_dropper