How to get array count of nested of nested object in elastic-search

ぐ巨炮叔叔 提交于 2019-12-11 09:49:32

问题


Can someone please help me to get an aggregated count of the nested sets object in elastic search, let say if my elastic search object as :

{
  "empId":12121,
  "entities": [
    {
      "sets": [
        {
          "setId": 1
        }
      ]
    }
  ]
}

entities are the type of array which contains an another array called sets. I wanted to get the count of sets of the filtered item.

{
"query": {
  "bool": {
    "filter": [
      {
        "terms": {
          "mediaItemId": [346754750,346745565]
        }
      }
    ]
  }
},
"size": 0,
"aggs": {
  "entities_agg": {
    "sum": {
      "script": {
        "inline": "params._source.entities.sets.size()"
      }
    }
  }
}
}

来源:https://stackoverflow.com/questions/49270141/how-to-get-array-count-of-nested-of-nested-object-in-elastic-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!