如何计算Elasticsearch中两个字段之间的差异?

时间:2016-11-01 19:23:41

标签: elasticsearch

SQL

SELECT lastTime - firstTime as result FROM times;

查询将如何查看 Elasticsearch

1 个答案:

答案 0 :(得分:1)

我找到了答案:

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