Elasticsearch-orderBy和groupBy数组

时间:2019-06-06 13:25:11

标签: elasticsearch

我正在尝试使用elasticsearch对多个数组进行排序。

我需要在7天内按所有视频观看次数(“ series.episodes.video.views”)对所有序列进行排序,并按唯一访问者(“ series.episodes.video.views.visitor”)将所有视频观看次数v分组。 (DESC)

elasticsearch中的数组:

序列号:

[{
  "name": "test",
  "id": 1,
  "series": [
    {
      "id": 1,
      "number": 1,
      "episodes": [
         {
           "part": 1,
           "id": 1,
           "video": {
              "id": 1,
              "views": [
                {
                  "id": 1,
                  "visitor": "sdfhfuiusdfhsd54",
                  "viewed_at": "1.1.2016 22:58:11"
                },
                {
                  "id": 2,
                  "visitor": "dfgdfgdfgdf",
                  "viewed_at": "1.1.2016 22:47:11"
                }
              ]
           }
         }
      ]
    }
  ]
},
{
  "name": "test 2",
  "id": 2,
  "series": [
    {
      "id": 10,
      "number": 1,
      "episodes": [
         {
           "part": 1,
           "id": 10,
           "video": {
              "id": 3,
              "views": [
                {
                  "id": 3,
                  "visitor": "sdfhfuiusdfhsd54",
                  "viewed_at": "1.1.2016 22:31:11"
                },
                {
                  "id": 4,
                  "visitor": "sdfhfuiusdfhsd54",
                  "viewed_at": "1.1.2016 22:40:11"
                }
              ]
           }
         }
      ]
    }
  ]
}
]

0 个答案:

没有答案