Hi i m trying to write a pipeline to find a missing field in an array of objects. So this is what i wrote.
PUT _ingest/pipeline/header-missing
{
"description": "header missing",
"version": 1,
"processors" : [
{
"script" : {
"source": """
for (item in ctx.request_headers) {
item.field_lower = item.header1;
if(ctx.item?.header1 == null){
item.field = "raj"
}
}
"""
}
}
]
}
Here is my simulate
POST /_ingest/pipeline/header-missing/_simulate?verbose
{
"docs": [
{
"_index": "index",
"_id": "id",
"_source": {
"request_headers": [
{
"header1": "one"
},
{
"header2": "two"
}
]
}
}
]
}
i think i m getting lost in finding value of an object. thus its printing "field " : "raj" on both fields. any help on what should i be doing ?
thanks
Raj