0

Considering the following document, I want to query only documents that have current location within 1mile of destination location.

{
  current_location: {
      lat: 34.0583,
      lon: -118.2476
  },
  destination_location: {
    lat: 33.989521,
    lon: -117.531614
 }

}

Game99
  • 227
  • 3
  • 6

1 Answers1

0

Use that geo distance filter:

{
   "query": {
        "filtered": {
            "filter": {
                "geo_distance": {
                    "distance": "1.6km",
                    "destination_location": "34.05,-118.24"
                }
            }
        }
   }
}

34.05 is the latitude and (-118.24) is the longitude.

1mile = 1.6km

RoiHatam
  • 876
  • 10
  • 19