ElasticSearch: access document nested value in groovy script

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:37:47

Use _source for nested properties. Doc holds fields that are loaded in memory. Nested documents may not be loaded and should be accessed with _source.

For instance:

GET index/type
    {
     "aggs": {
      "NAME": {
      "scripted_metric": {
        "init_script": "_agg['collection']=[]",
        "map_script": "_agg['tr'].add(_source.propertry1.prop);",
        "combine_script": "return _agg",
        "reduce_script": "return _aggs"
      }
    }
  },
  "size": 0
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!