Ygor Fraga
Ygor Fraga

Reputation: 143

Geopoint with an array

I have got a DOC 'company' and a TYPE 'user'. Inside 'user' there is a field called 'locations' and this is an array. Every location has a field called 'point' which is a GeoPoint as a string "40.748770,-73.985487". How can I get the points nearby this point?

This example I'm showing bellow is not working:

GET /company/user/_search
{
    "query": {
        "bool" : {
            "must" : {
                "match_all" : {}
            },
            "filter" : {
                "geo_distance" : {
                    "distance" : "500m",
                    "locations.point" : "40.748770, -73.985487"
                }
            }
        }
    }
}

Upvotes: 0

Views: 183

Answers (1)

Gautam V.
Gautam V.

Reputation: 536

Below example might help you,

GET /company/user/_search
{
  "query": {
    "filtered": {
      "filter": {
        "geo_distance": {
          "distance": "1km", 
          "location": { 
            "lat":  40.715,
            "lon": -73.988
          }
        }
      }
    }
  }
}

Upvotes: 1

Related Questions