kusha
kusha

Reputation: 63

Querying titan graph for only indexed vertices without traversing complete graph

I am trying to retrieve only indexed vertices in the graph

I used the below query

Iterator<Vertex> vertices = titanTransaction.query().has("name").vertices().iterator();

This query traverses to the complete graph and fetches the result, Can anyone suggest me a better way, The name vertex is indexed.

Thanks

Upvotes: 1

Views: 98

Answers (2)

Curtis Allen
Curtis Allen

Reputation: 873

You should be able to use the .has(key,value) method https://github.com/thinkaurelius/titan/blob/0.5.4/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/query/graph/GraphCentricQueryBuilder.java#L113

Iterator<Vertex> vertices = titanTransaction.query().has("name","john").vertices().iterator();

Should do the trick.

Upvotes: 2

Faber
Faber

Reputation: 1552

Have you tried:

graph.V('name','nameOfTargetVertex').next()

I think this should use your index on the attribute name, according to http://gremlindocs.com/#transform/v .

Upvotes: 1

Related Questions