Bird
0
0

Given this Elasticsearch document indexed with a geo_point field location:

medium📝 Predict Output Q13 of 15
Elasticsearch - Mappings and Data Types

Given this Elasticsearch document indexed with a geo_point field location:

{ "location": { "lat": 40.7128, "lon": -74.0060 } }

Which query will correctly find documents within 10km of this point?

A{ "range": { "location": { "gte": "10km" } } }
B{ "geo_shape": { "location": { "shape": { "type": "point", "coordinates": [40.7128, -74.0060] }, "relation": "within" } } }
C{ "term": { "location": "40.7128,-74.0060" } }
D{ "geo_distance": { "distance": "10km", "location": { "lat": 40.7128, "lon": -74.0060 } } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct query type for geo_point

    For geo_point, geo_distance query finds documents within a distance from a point.
  2. Step 2: Check query syntax and parameters

    { "geo_distance": { "distance": "10km", "location": { "lat": 40.7128, "lon": -74.0060 } } } uses geo_distance with correct distance and point coordinates.
  3. Final Answer:

    { "geo_distance": { "distance": "10km", "location": { "lat": 40.7128, "lon": -74.0060 } } } -> Option D
  4. Quick Check:

    geo_distance query = { "geo_distance": { "distance": "10km", "location": { "lat": 40.7128, "lon": -74.0060 } } } [OK]
Quick Trick: Use geo_distance for points, geo_shape for polygons [OK]
Common Mistakes:
MISTAKES
  • Using geo_shape query on geo_point field
  • Wrong coordinate order in geo_shape
  • Using term or range queries for geo data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes