Web サイトの各ページ ビューを ES インデックスに保存しています。各ページはentity_idによって認識されます。特定の時点以降の一意のページ ビューの合計数を取得する必要があります。次のマッピングがあります。
{
"my_index": {
"mappings": {
"page_views": {
"_all": {
"enabled": true
},
"properties": {
"created": {
"type": "long"
},
"entity_id": {
"type": "integer"
}
}
}
}
}
}
Elasticsearch docs によると、それを行う方法はカーディナリティ集計を使用することです。これが私の検索リクエストです。
GET my_index/page_views/_search
{
"filter": {
"bool": {
"must": [
[
{
"range": {
"created": {
"gte": 9999999999
}
}
}
]
]
}
},
"aggs": {
"distinct_entities": {
"cardinality": {
"field": "entity_id",
"precision_threshold": 100
}
}
}
}
将来のタイムスタンプを使用したため、結果が返されないことに注意してください。そして、私が得ている結果は次のとおりです。
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
},
"aggregations": {
"distinct_entities": {
"value": 116
}
}
}
検索クエリのページ訪問がまったくないことを考えると、一意のページ訪問が 116 になる理由がわかりません。私は何を間違っていますか?