0
votes

Is it possible to make a geospatial vertex centric index in Titan?

I've tried following the patterns in the guide https://github.com/thinkaurelius/titan/wiki/Vertex-Centric-Indices to create one in the rexster console, but failed.

geo_location=g.makeKey("geo_location").dataType(Geoshape.class).make();
g.makeLabel("edge_label").sortKey(geo).signature(geo).make();

==>An error occurred while processing the script for language [groovy].
All transactions across all graphs in the session have been concluded with failure:    
java.util.concurrent.ExecutionException:
javax.script.ScriptException: 
javax.script.ScriptException:
java.lang.IllegalArgumentException:
Key must have comparable data type to be used as sort key: geo_location

I have tried creating a regular geospatial index, but this gives low performance when querying vertices with a high number of edges with the geospatial property in question.

I envision this as being able to do the following and retrieve all edges within the circle, preferably sorted by distance from (x,y).

x = 0
y = 0
radius = 10
circle = Geoshape.circle(current_position_x, current_position_y, nearby_radius)
some_vertex_with_centric_index.outE('edge_label').has(location, WITHIN, circle)

Using Titan Server 0.4.4 w/Cassandra 2.0.3 + elastic search

1

1 Answers

0
votes

I don't think this is / can be possible. Sort key sort edges either ascending or descending. How would you sort location in any order? What I would do in your case is this:

  • precalculate the distance from vertex A to vertex B
  • store the precalculated distance as an edge property
  • use the precalculated distance as sort key

Then query like this:

location.outE('edge_label').has('distance', T.lte, radius).inV()

Cheers, Daniel