If create a runtime field for searches with aggregations.
PUT /work-analyzers/_mapping
{
"runtime": {
"total_consumption": {
"type": "double",
"script": {
"source": """
emit(doc['pa1_w'].value + doc['pa2_w'].value + doc['pa3_w'].value)
"""
}
}
}
}
Work fine but if anytime search when the search ever reaches a document that has (I assume) null values in all three fields that make up the runtime field, an exception is thrown.
I have looked for the output, but in all it fails, when executing the creation of the calculated field, and I can't find the topic doc[<field>].size()==0
"caused_by": {
"type": "illegal_state_exception",
"reason": "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
}
Search fails with size 100 (not with 10 or 30)
GET /work-analyzers/_search
{
"size": 100,
"query": {
"range": {
"total_consumption": {
"gt": 700,
"boost": 1
}
}
},
"_source": false,
"fields": [
{
"field": "pa1_w"
},
{
"field": "pa2_w"
},
{
"field": "pa3_w"
},
{
"field": "total_consumption"
}
],
"sort": [
{
"_doc": {
"order": "asc"
}
}
],
"track_total_hits": -1
}
Apreciate help.