Aggregation of Elasticearch Cardinality gives completely incorrect results

I save every pageview of a website in the ES index, where each page is recognized by entity_id . I need to get the total number of unique pageviews from a specific point in time. I have the following mapping:

{
   "my_index": {
      "mappings": {
         "page_views": {
            "_all": {
               "enabled": true
            },
            "properties": {
               "created": {
                  "type": "long"
               },
               "entity_id": {
                  "type": "integer"
               }
            }
         }
      }
   }
}

According to Elasticsearch docs, the way to do this is to use power aggregation. Here is my request:

GET my_index/page_views/_search
{
  "filter": {
    "bool": {
      "must": [
        [
          {
            "range": {
              "created": {
                "gte": 9999999999
              }
            }
          }
        ]
      ]
    }
  },
  "aggs": {
    "distinct_entities": {
      "cardinality": {
        "field": "entity_id",
        "precision_threshold": 100
      }
    }
  }
}

Please note that I used the timestamp in the future, so the results are not returned. And I get the result:

{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 0,
      "max_score": null,
      "hits": []
   },
   "aggregations": {
      "distinct_entities": {
         "value": 116
      }
   }
}

I don’t understand how unique page visits can be 116, so there are no page visits for a search query at all. What am I doing wrong?

+4
1

. , , , , , . ( ), , , :

curl -XPOST "http://localhost:9200/my_index/page_views/_search " -d'
{
   "size": 0, 
   "aggs": {
      "filtered_entities": {
         "filter": {
            "bool": {
               "must": [
                  [
                     {
                        "range": {
                           "created": {
                              "gte": 9999999999
                           }
                        }
                     }
                  ]
               ]
            }
         },
         "aggs": {
            "distinct_entities": {
               "cardinality": {
                  "field": "entity_id",
                  "precision_threshold": 100
               }
            }
         }
      }
   }
}'

:

{
   "took": 1,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 4,
      "max_score": 0,
      "hits": []
   },
   "aggregations": {
      "filtered_entities": {
         "doc_count": 0,
         "distinct_entities": {
            "value": 0
         }
      }
   }
}

, :

http://sense.qbox.io/gist/bd90a74839ca56329e8de28c457190872d19fc1b

Elasticsearch 1.3.4, .

+3

All Articles