在弹性搜索中获取字段的唯一值

时间:2018-06-14 07:23:21

标签: php elasticsearch

我希望在名为IDFA的字段中,在过去90天内每天获取一个唯一数量的值。

所以我的弹性搜索查询是:

"aggs"=> [
                "byapp"=> [
                  "terms"=> [
                    "field"=> "idapp",
                    "order"=> [
                      "_count"=> "desc"
                    ]
                  ],



          "aggs"=> [

                            "daily_data"=> [
                                            "date_histogram"=> [
                                              "field"=> "happenon",
                                             "interval"=> "day",
                                             "format"=> "yyyy-MM-dd",
                                             "order"=> [
                                               "_key"=> "desc"
                                                       ]
                                               ],  
                                      "aggs" => [

                                        "type_count" => [
                                              "cardinality" => [
                                                "field" => "idfa",
                                                "precision_threshold" => 100
                                              ]
                                              ,
                                              "aggs"=> [
                                                 "bucket_truncate"=> [
                                                       "bucket_sort"=> [
                                                         "from"=> 1,
                                                         "size"=> 90
                                                       ]
                                                 ]
                                             ]          
                           ]


                                      ]    

                     ]
                          ]
                        ]
                      ]

这里我已经通过app id进行了聚合,然后根据最近90天进行聚合。最后,我还需要在IDFA中找到一些独特的值。

如果有人能够回答这个问题的话。这将对我的项目更有帮助..提前致谢

0 个答案:

没有答案