elasticsearch 查询不返回结果

gc0ot86w  于 5个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(63)

我想检查failure_error_code中的所有值。如果我从查询中删除exists,它可以工作,但它会返回我不想要的Meta字段。在过去的90天里,我有29344个文档,但它只显示了几个文档。
有谁知道如何在不显示Meta字段的情况下为特定字段选择所有值?

GET rds_database-*/_search
{
  "fields": [
    "failure_error_code.keyword"
  ],
  "query": {
    "bool": {
      "filter": [
        {
            "term":{
              "status.keyword":"F"
              
            }
            },
            {
              "exists": {
                "field": "failure_error_code.keyword"
              }
            },
            {
            "range":
            {
              "@timestamp":
              {
                "gte":"now-1y/d",
                "lte":"now/d"
              }
            }
            }
      ]
    }
  }
}

字符串

dphi5xsq

dphi5xsq1#

您可以使用terms聚合来实现这一点。
基于多桶值源的聚合,其中动态构建桶-每个唯一值一个。

PUT test_term_aggs/_doc/1
{
  "failure_error_code": "404"
}
PUT test_term_aggs/_doc/2
{
  "failure_error_code": "402"
}
GET test_term_aggs/_search
{
  "size": 0,
  "aggs": {
    "NAME": {
      "terms": {
        "field": "failure_error_code.keyword"
      }
    }
  }
}

x1c 0d1x的数据

相关问题