Book Image

ElasticSearch Blueprints

Book Image

ElasticSearch Blueprints

Overview of this book

Table of Contents (15 chapters)
Elasticsearch Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

The maximum distance covered


Now, let's move on to another example of finding restaurants that are within 10 kms from my current position. Those that are beyond 10 kms are of no interest to me. So, it almost makes up to a circle with a radius of 10 km from my current position, as shown in the following map:

Our best bet here is using a geo distance filter. It can be used as follows:

curl -XPOST 'http://localhost:9200/restaurants/_search' -d '{
  "query": {
    "filtered": {
      "filter": {
        "geo_distance": {
          "distance": "100km",
          "location": {
            "lat": 1.232,
            "lon": 1.112
          }
        }
      }
    }
  }
}'