Hi, I have two inventory fields:
- inventory.warehouse1.availableInventory: 10
- inventory.warehouse2.availableInventory: 20
I need to make a query with sum of these two fields and make a boost if total > 0.
I try to make runtime total field but get an error.
PUT product/_mapping
{
"runtime": {
"total": {
"type": "long",
"script": {
"source": "emit(doc['inventory.warehouse1.availableInventory'].value +
doc['inventory.warehouse2.availableInventory'].value)"
}
}
}
}
Error:
"reason": "Root mapping definition has unsupported parameters: [runtime :
{total={type=long, script=.
{source=emit(doc['inventory.warehouse1.availableInventory'].value +
doc['inventory.warehouse2.availableInventory'].value)}}}]"
How to make sum of two fields and make condition > 0?