elasticsearchelasticsearch-queryelasticsearch-geo-shape

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


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"
          }
        }
          
        }
      ]
    }
  }
}  

Solution

  • 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.