“[geo_distance] 格式错误的查询,预计 [END_OBJECT] 但发现 [FIELD_NAME]”

"[geo_distance] malformed query, expected [END_OBJECT] but found [FIELD_NAME]"

我尝试创建搜索查询,其值在 1500 万个收音机和 3 周之间。我尝试执行此查询:

"query": {
"bool": {
  "must": {
    "match_all": {}
  }
, "filter": [
  {
    "geo_distance": {
     
      "distance": "1000km",
      "geoLocation": {
        "lat": 31.966467334184614,
        "lon": 35.83242623178664
      }
    }
    ,
   "range": {
      "map_date": {
        "gte": "now-3w/w",
        "lte": "now/w"
      }
    }
    
  }
]
}}

我提交的日期是:map_date,我提交的地理点是geoLocation

我收到这样的回复:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "[geo_distance] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line" : 18,
        "col" : 8
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[18:8] [bool] failed to parse field [filter]",
    "caused_by" : {
      "type" : "parsing_exception",
      "reason" : "[geo_distance] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
      "line" : 18,
      "col" : 8
    }
  },
  "status" : 400
}

请帮我找出我做错了什么

您的过滤器部分格式错误,请尝试:

{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": [
        {
          "geo_distance": {
            "distance": "1000km",
            "geoLocation": {
              "lat": 31.966467334184614,
              "lon": 35.83242623178664
            }
          }
        },
        {
          "range": {
            "map_date": {
              "gte": "now-3w/w",
              "lte": "now/w"
            }
          }
        }
      ]
    }
  }
}

如果您的过滤器数组列出了 {} 列表,请查看: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html