Geo Bounding Box Filter

Hi ,
While trying geo_bounding_box following error is generated. Can you please help me out in resolving the error

Code:

GET /attractions/restaurant/_search
    {
      "query": {
        "filtered": {
          "filter": {
            "geo_bounding_box": {
              "location": { 
                "top_left": {
                  "lat":  40.8,
                  "lon": -74.0
                },
                "bottom_right": {
                  "lat":  40.7,
                  "lon": -73.0
                }
              }
            }
          }
        }
      }
    }

Response :

{
      "error": {
        "root_cause": [
          {
            "type": "parsing_exception",
            "reason": "no [query] registered for [filter]",
            "line": 6,
            "col": 21
          }
        ],
        "type": "parsing_exception",
        "reason": "no [query] registered for [filter]",
        "line": 6,
        "col": 21
      },
      "status": 400
    }tered]",
        "line": 3,
        "col": 17
      },
      "status": 400
    }

It should be like this.

GET /_search
{
    "query": {
        "bool" : {
            "must" : {
                "match_all" : {}
            },
            "filter" : {
                "geo_bounding_box" : {
                    "pin.location" : {
                        "top_left" : {
                            "lat" : 40.73,
                            "lon" : -74.1
                        },
                        "bottom_right" : {
                            "lat" : 40.01,
                            "lon" : -71.12
                        }
                    }
                }
            }
        }
    }
}

Still receiving some errors
Data :

PUT /attractions/restaurant/1
{
  "name":     "Chipotle Mexican Grill",
  "location": "40.715, -74.011" 
}

PUT /attractions/restaurant/2
{
  "name":     "Pala Pizza",
  "location": { 
    "lat":     40.722,
    "lon":    -73.989
  }
}

PUT /attractions/restaurant/3
{
  "name":     "Mini Munchies Pizza",
  "location": [ -73.983, 40.719 ] 
}

Searching :

GET /attractions/restaurant/_search
    {
        "query": {
            "bool" : {
                "must" : {
                    "match_all" : {}
                },
                "filter" : {
                    "geo_bounding_box" : {
                        "pin.location" : {
                            "top_left" : {
                                "lat" : 40.73,
                                "lon" : -74.1
                            },
                            "bottom_right" : {
                                "lat" : 40.01,
                                "lon" : -71.12
                            }
                        }
                    }
                }
            }
        }
    }

Error :

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to find geo_point field [pin.location]",
        "index_uuid": "UN1axDBhQUK1hbyEjCq_Rw",
        "index": "attractions"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "attractions",
        "node": "MZOPRP3TTTev18if9HD8qA",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to find geo_point field [pin.location]",
          "index_uuid": "UN1axDBhQUK1hbyEjCq_Rw",
          "index": "attractions"
        }
      }
    ]
  },
  "status": 400
}

Try with location instead as pin.location does not exist.

Thank You @dadoonet this works fine :smile: :+1:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.