mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Document using stored scripts for ingest (#58783)
This documents using stored scripts for complex conditionals in indest.
This commit is contained in:
parent
f63cbad629
commit
326cce624b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user