我要分别存储以下search
和click on the search result
。
{
"_index": "reviewmeta_searchlog_index",
"_type": "doc",
"_id": "4016313",
"_score": 1,
"_source": {
"id": 4016313,
"created_at": "2019-03-04T09:37:56.140819+00:00",
"search_data": {
"query": "서대문자연사",
"screen": "search",
"variant_name": "a",
"order_by": "default",
"page": "1",
"result_count": 760,
"sort_by": "popular"
},
"click_1": 1,
"result_count": 760,
"user": {
"id": 273412
},
"clicks": [
{
"review_meta": {
"name": "서대문 자연사 박물관",
"location": {
"lon": 126.937755689287,
"lat": 37.576744115598
},
"id": 371
},
"created_at": "2019-03-04T09:37:58.975258+00:00",
"id": 1717585,
"position": 1
},
{
"review_meta": {
"name": "서대문 자연사 박물관",
"location": {
"lon": 126.937755689287,
"lat": 37.576744115598
},
"id": 371
},
"created_at": "2019-03-04T09:38:01.819918+00:00",
"id": 1717586,
"position": 1
}
]
},
"fields": {
"created_at": [
"2019-03-04T09:37:56.140Z"
]
}
}
我希望每天获得点击次数最多的搜索关键字,并使用以下搜索。
GET reviewmeta_searchlog_index/_search
{
"size" : 0,
"aggs": {
"clicks": {
"date_histogram": {
"field": "created_at",
"interval": "day"
},
"aggs": {
"per_query_sum": {
"terms": {
"field": "search_data.query.keyword"
},
"aggs": {
"count_click": {
"cardinality": { "field": "clicks.id" }
}
}
}
}
}
}
}
我的搜索没问题吗? (我不确定cardinality
是否在做我打算做的事情)