Elasticsearch _search 不提供结果

Elasticsearch _search not providing results

我正在尝试 return 我的索引中的所有名称字段和计数字段,但是当我尝试搜索数据时,没有数据被 return 编辑(如上一个代码存根所示)。我的索引中肯定有数据。我的 _search 命令做错了什么?

我的映射:

PUT /visual
{
  "mappings": {
     "properties": {
        "@timestamp": {"type": "date"},
        "name": {
           "type" : "text",
              "fields" : {
                 "keyword" : {
                     "type" : "keyword"
            }
          }
        },
        "count": {"type": "integer"},
        "err": {"type": "integer"},
        "delta1": {"type": "integer"},
        "str_list": {"type": "text"}
     }
  }
}

我尝试 return 名称字段、计数字段和时间戳的搜索命令:

POST visual/_search

{
  "query":{
    "range":{
      "order_date":{
        "gte":"now-80d"
      }
    }
  },
    "aggs": {
      "names":{
        "terms":{"field":"name.keyword"},
    "aggs": {
      "counts":{
        "terms":{"field":"count"},
    "aggs": {
        "time_buckets": {
          "date_histogram": {
            "field": "@timestamp",
            "fixed_interval": "1h",
            "extended_bounds": {
              "min": "now-80d"
            },
          "min_doc_count": 0
          }
        }
    }
    }
    }
    }
    },"size":100

}

没有数据的响应 return编辑:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "names" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [ ]
    }
  }
}

在您的范围查询中,您使用的字段 order_field 在您的映射中不存在。所以也许使用 @timestamp 已经解决了问题?

"query":{
    "range":{
      "@timestamp":{
        "gte":"now-80d"
      }
    }
  }

查看 range query doc 了解更多信息。