【问题标题】:"[geo_distance] malformed query, expected [END_OBJECT] but found [FIELD_NAME]"“[geo_distance] 格式错误的查询,应为 [END_OBJECT] 但找到 [FIELD_NAME]”
【发布时间】:2021-01-07 17:21:59
【问题描述】:

我试图在 15m 收音机和 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"
      }
    }
    
  }
]
}}

我提交的日期是:ma​​p_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
}

请帮我弄清楚我做错了什么

【问题讨论】:

    标签: elasticsearch elastic-stack


    【解决方案1】:

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

    {
      "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

    【讨论】:

      猜你喜欢
      • 2018-02-10
      • 2018-04-25
      • 2021-04-22
      • 2020-02-26
      • 2018-01-30
      • 2022-10-25
      • 2022-01-14
      • 2017-12-01
      • 2020-08-30
      相关资源
      最近更新 更多