how to calculate the difference between the two fields in Elasticsearch? how to calculate the difference between the two fields in Elasticsearch? elasticsearch elasticsearch

how to calculate the difference between the two fields in Elasticsearch?


I found answer:

{   "size": 10,    "script_fields": {      "duration": {        "script": "doc[\"lastTime\"].date.getMillis()/1000  - doc[\"firstTime\"].date.getMillis()/1000"      }    }  }