in SQL :
SELECT lastTime - firstTime as result FROM times; What will the query look like in Elasticsearch ?
in SQL :
SELECT lastTime - firstTime as result FROM times; What will the query look like in Elasticsearch ?
The easiest way is to use script_fields in a query.
{ "query" : { "match_all": {} }, "script_fields": { "result": { "script": "doc['lastTime'].value - doc['firstTime'].value" } } } Mathematical action will be performed only if both fields are of type integer or float. Otherwise concatenation. Check mapping.
Source: https://ru.stackoverflow.com/questions/585660/
All Articles