location as geo_pointarea field as geo_shapelocation as geo_pointarea field as geo_shapeplaces with a mapping that has a location field of type geo_point and an area field of type geo_shape.Use the PUT method to create the index and define location as geo_point and area as geo_shape in the mappings.
places index with location set to latitude 40.7128 and longitude -74.0060, and area set to a polygon shape with coordinates [[[-74.0, 40.7], [-74.0, 40.8], [-73.9, 40.8], [-73.9, 40.7], [-74.0, 40.7]]].Use PUT /places/_doc/1 to add a document. Set location with lat and lon. Define area as a polygon with the given coordinates.
places index to find documents where the location is within 5km of latitude 40.7130 and longitude -74.0070 using a geo_distance query.Use a geo_distance query with distance set to "5km" and location coordinates as given.
places index to find documents where the area intersects with a polygon shape defined by coordinates [[[-74.005, 40.705], [-74.005, 40.715], [-73.995, 40.715], [-73.995, 40.705], [-74.005, 40.705]]].Use a geo_shape query with relation set to "intersects" and the polygon coordinates given.
What is the main difference between geo_point and geo_shape types in Elasticsearch?
geo_point typegeo_point stores a single geographic location using latitude and longitude coordinates.geo_shape typegeo_shape stores complex geographic shapes such as polygons, lines, or multi-points.geo_point stores a single location; geo_shape stores complex shapes like polygons. -> Option AWhich of the following is the correct way to define a geo_point field in an Elasticsearch mapping?
{
"properties": {
"location": {
"type": "?"
}
}
}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?
geo_point, geo_distance query finds documents within a distance from a point.geo_distance with correct distance and point coordinates.What is wrong with this Elasticsearch mapping for a geo_shape field named area?
{
"properties": {
"area": {
"type": "geo_point"
}
}
}The data to be stored is a polygon shape.
geo_shape type, not geo_point.geo_point which only supports single points, so it cannot store polygons.geo_shape to store polygons. -> Option AYou want to store a city boundary as a polygon and find all points inside it. Which Elasticsearch setup is correct?
{
"mappings": {
"properties": {
"city_boundary": { "type": "?" },
"user_location": { "type": "?" }
}
}
}Choose the correct types for city_boundary and user_location.
geo_shape type.geo_point type.geo_shape to city_boundary and geo_point to user_location.Pass the test and this pattern moves unknown