ES-Python:代码正在运行,但未生成匹配

时间:2018-10-31 08:55:26

标签: python elasticsearch

我正在尝试使用python从elasticsearch提取数据。该代码已成功运行,但未产生任何匹配。同时,当我在elasticsearch中运行相同的代码时,它正在运行并生成匹配。

代码如下:

res = es.search(index='opm', body ={
"size": 0,
"_source": ["event_id", "edition_id", "subscription.keyword","daystogo"],
"query": {
  "bool": {
   "must": [
    {
      "range": {
        "interaction_ts": {
          "gte": 1540166400,
          "lte": 1540771199}}}]}},
"aggs": {
  "group_by_event": {
    "terms": {
      "field": "event_id"},
    "aggs": {
      "group_by_edition": {
         "terms": {
        "field": "edition_id"
      },
      "aggs": {
        "group_by_subscription": {
          "terms": {
            "field": "subscription"
          },
          "aggs": {
            "group_by_daystogo": {
              "terms": {
                "field": "daystogo"
              },
              "aggs": {
                "impression_count": {
                  "value_count": {
                    "field": "impression"
                  }
                },
                "unique_impression_count": {
                  "cardinality": {
                    "field": "user"
                  }
                },
                "pageview_count": {
                  "filter": {
                    "term": {
                      "placement": "pageview"
                    }
                  },
                  "aggs": {
                    "pv_count": {
                      "value_count": {
                        "field": "placement"
                      }   }}}}}}}}}}}}})

我收到的res的输出是:

{'took': 0,'timed_out': False,
'_shards': {'total': 2, 'successful': 2, 'skipped': 0, 'failed': 0},
'hits': {'total': 0, 'max_score': 0.0, 'hits': []},
'aggregations': {'group_by_event': {'doc_count_error_upper_bound': 0,
'sum_other_doc_count': 0,
'buckets': []}}}

请帮助我了解代码是否错误或方法是否错误以及应更改哪些内容,以便代码正常工作

0 个答案:

没有答案