Reputation: 1858
TitanDB 1.0.0 (on top of DynamoDB)
Gremlin 3
I've got a set of vertices with a label a. I have a property of type long on those vertices which corresponds to the time in milliseconds from 1970 UTC (timestamp of when the vertex was created.) When I pull back those vertices I want to be able to pull them back in decsending order.
How can I create an index on that property in the decr order in Titan Management System?
Documentation seems vague on that.
Closest thing I found is
public RelationTypeIndex buildPropertyIndex(PropertyKey key,
String name,
Order sortOrder,
PropertyKey... sortKeys)
But what do I put in as the key and sortKeys? I want to be able to pull the whole vertex ordered by the timestamp property
Edit: The only way I know of doing this at the minute is by duplicating that property on the edge and using a vertex centric index on the edge to increase the performance.
Upvotes: 2
Views: 417
Reputation: 3565
I do something similar as I order by the release date of a particular product. If you want to execute order().by("Value", decr)
efficiently then I highly recommend reading into mixed indices specified here. Mixed indices allow these operations to be done quickly.
An example of what you may be looking for:
TitanGraph graph = TitanFactory.open(config);
TitanManagement mgmt = graph.openManagement();
PropertyKey key = mgmt.makePropertyKey("TimeStamp").dataType(Long.class).make();
mgmt.buildIndex("timeStampIndex", Vertex.class).addKey(key).buildMixedIndex("search");
mgmt.commit();
The above index lets me execute the following query very quickly:
g.V().order().by("TimeStamp", decr);
Which gets me the time stamps in descending order. The above traversal will work without indexing but can be slow in large graphs.
Upvotes: 9