Boost based on value of sum two fields

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 + 


 "reason": "Root mapping definition has unsupported parameters: [runtime : 
{total={type=long, script=. 
  {source=emit(doc['inventory.warehouse1.availableInventory'].value + 

How to make sum of two fields and make condition > 0?

What version of Elasticsearch are you running?

Elastisearch version 7.10

Runtime fields were added in 7.11.

Given 7.10 is unsupported, as is 7.11, you should be upgrading to 7.17 at a minimum.

1 Like