Let's say I have the following mapping with hundreds of millions of docs currently populating the index:
{
"properties": {
"a": { "type": "integer" },
"b": { "type": "integer" },
"c": { "type": "integer" }
}
}
I would like to query by the sum of two or more of these fields. It seems that script query is the way to go, so I put together the following query:
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"lang": "painless",
"source": "(doc['a'].value + doc['b'].value + doc['c'].value) > params.sum",
"params": {
"sum": 20
}
}
}
}
}
}
}
However, this is incredibly slow, taking several seconds to complete. Is there a more efficient way to accomplish this?
Thanks