Elasticsearch '[bool] failed to parse field [filter]'

2.6k Views Asked by At

I'm trying to solve parsing exception of my search query. "type" : "x_content_parse_exception", "reason" : "[18:9] [bool] failed to parse field [filter]" I hope someone can help me thanks

GET /g20/_search
{ "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": [
        {"geo_shape": {
          "location": {
            "shape": {
              "type": "envelope",
              "coordinates": [
                [39,-77],
                [38,-76]
              ]
            },
            "relation": "within"
          }
        }
          
        }
      ]
    }
  }
}  
1

There are 1 best solutions below

0
Joe - Check out my books On BEST ANSWER

You'll need to reverse the coordinate order b/c the coordinates you've provided are in Antarctica, not around D.C. as you likely intentioned:

GET /g20/_search
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": [
        {
          "geo_shape": {
            "location": {
              "shape": {
                "type": "envelope",
                "coordinates": [
                  [ -77, 39 ],
                  [ -76, 38 ]
                ]
              },
              "relation": "within"
            }
          }
        }
      ]
    }
  }
}  

In the envelope spec, lon is followed by lat.