Hello!
I have such aggregation.
"aggs":{
"child_id":{
"terms":{
"script":{
"lang":"painless",
"source":"params['_source']['prod_list'][params['_source']['prod_list'].indexOf(params.prod) + 1]",
"params":{"prod":6384}
},
"size":1000
}
}
}
EOF
But it is too slow. As i understand from docs - because of parsing _source
for every matching document - it is very expensive operation.
So i need some way to optimize this aggregation.
Idea of it - get next value from prod_list
after matched one ("params":{"prod":6384}
).
I tried to use doc.prod_list
in script - but it make wrong results - items in doc.prod_list
has different order than in params['_source']['prod_list']
.
Does anyone have some idea?
Thanks for everyone who can help!