0
0
Elasticsearchquery~20 mins

Geo-point and geo-shape types in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Geo Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this geo-point query?
Given the following Elasticsearch query, what will be the number of hits returned if the index contains documents with geo-points at (40, -70), (41, -71), and (39, -69)?
Elasticsearch
{
  "query": {
    "geo_distance": {
      "distance": "100km",
      "location": {
        "lat": 40,
        "lon": -70
      }
    }
  }
}
A0
B2
C3
D1
Attempts:
2 left
💡 Hint
Think about which points fall within 100km radius of (40, -70).
🧠 Conceptual
intermediate
1:30remaining
Which geo-shape type represents a polygon with holes?
In Elasticsearch geo-shape types, which of the following correctly represents a polygon with holes inside it?
AA MultiPoint with points inside the polygon area
BA LineString with multiple segments forming a closed loop
CA Polygon with multiple linear rings, where the first ring is the outer boundary and subsequent rings are holes
DA Point with a radius representing the hole
Attempts:
2 left
💡 Hint
Think about how polygons with holes are defined in geojson format.
🔧 Debug
advanced
2:30remaining
Why does this geo_shape query fail?
This geo_shape query returns an error. What is the cause?
Elasticsearch
{
  "query": {
    "geo_shape": {
      "location": {
        "shape": {
          "type": "circle",
          "coordinates": [-70, 40],
          "radius": "100km"
        },
        "relation": "intersects"
      }
    }
  }
}
AElasticsearch does not support 'circle' type in geo_shape queries
BThe coordinates are in wrong order; should be [lat, lon]
CThe radius value must be a number, not a string
DThe relation 'intersects' is invalid for geo_shape queries
Attempts:
2 left
💡 Hint
Check the supported geo_shape types in Elasticsearch.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in this geo-point mapping
Which option contains the correct syntax for defining a geo_point field in an Elasticsearch mapping?
A"location": { "type": "geo_point" }
B"location": { "geo_point": true }
C"location": { "type": "geo-point" }
D"location": { "type": "point_geo" }
Attempts:
2 left
💡 Hint
Check the exact spelling of the geo_point type.
🚀 Application
expert
3:00remaining
How many shapes are indexed with this geo_shape document?
Given this document indexed in Elasticsearch with a geo_shape field 'area': { "area": { "type": "geometrycollection", "geometries": [ { "type": "point", "coordinates": [100.0, 0.0] }, { "type": "linestring", "coordinates": [[101.0, 0.0], [102.0, 1.0]] }, { "type": "polygon", "coordinates": [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]] } ] } } How many individual shapes does this geo_shape field contain?
A0
B3
C1
D4
Attempts:
2 left
💡 Hint
Count each geometry inside the GeometryCollection.