类型语法没有返回分类数据

时间:2018-01-03 14:24:09

标签: rest elasticsearch

AS title我的数据索引是:" ntopng-2018.01.02"

这是我的REST API:

GET ntopng-2018.01.02/_search
{
    "size": 0,
    "query": {
        "bool": {
            "should": [{
                    "term": {
                        "IPV4_SRC_ADDR": "120.127.160.91"
                    }
                },
                {
                    "term": {
                        "IPV4_DST_ADDR": "120.127.160.91"
                    }
                }
            ],
            "minimum_should_match": 1,
            "must": [{
                "range": {
                    "LAST_SWITCHED": {
                        "gte": 1514800209
                    }
                }
            }]
        }
    },
    "aggs": {
        "genres": {
            "terms": {
                "field": "L7_PROTO_NAME.keyword"
            }

            ,
            "aggs": {
                "in_bytes": {
                    "sum": {
                        "field": "IN_BYTES"
                    }
                }
            }
        }
    }
}

和回复:

{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 6,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 282,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "genres": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    }
  }
}

它没有对L7_PROTO_NAME进行分类,但如果我更改为另一个索引" logstash-2018.01.02" (相同的数据类型字段),它将返回分类数据。

这是我的数据https://gist.github.com/Howard-Chang/808ed0f4c64c528051f284cee3ac0634

1 个答案:

答案 0 :(得分:0)

确定。我发现这是旧的ES版本问题。 如果索引不是“logstash- *”,我不能使用类型语法来查询并返回正确的结果。 但在我更新到最新的6.1.1版本后,它现在可以运行了!