Search using geospatial values
Geospatial search
Geospatial search is used to discover geospatial relationships. Search indexes make such searches possible. First, a search index must be created.
schema.vertexLabel('location').
searchIndex().
ifNotExists().
by('loc_id').asString().
by('geo_point').by('loc_details').
create()
This query is looking for all fridge sensors that are located at homes and meet the requirement of being inside the described circle that is designated as a circle with a center at (118, 34) and a radius of 20 degrees with the method Geo.inside()
.
The in().in()
steps allow the query to traverse from the location
vertices to the home
vertices and then to the fridge_sensor
vertices.
g.V().hasLabel('location').
has('geo_point', Geo.inside(Geo.point(118,34),20, Geo.Unit.DEGREES)).
in().in()
Other indexes will probably be required for the |
results in:
==>v[dseg:/fridge_sensor/31/100/55555/1]
==>v[dseg:/fridge_sensor/31/200/55556/3]
More information on geospatial queries can be found in Geospatial traversals. The main point here is that the geospatial portion of the query can only be met using a search index.