Search using geospatial values

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 in().in() portion of this query, but the error message will display the indexes that must be created.

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.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com