elasticsearch dynamic query - Add another field to each document returned
问题 What I need is very simple, but I am unable to find how to do it in Elasticsearch, possibly because of the complexity of what is required to be done. Input (two sample JSON documents) { "car" : 150, "bike" : 300 } { "car" : 100, "bike" : 200} What I want in return is that when I fire a search query it returns me the documents with an extra field inventory which is defined as the sum of number of cars and bikes. And in the sorted order. Sample Output: hits: [ { "car" : 150, "bike" : 300,