Question

Per the latest Titan 0.4.1 docs, this code should work to order vertices in a result set:

graph.query().has("name",CONTAINS,"john").orderBy("age",Order.DESC).limit(10).vertices()

I would like to perform this type of query across a potentially large set of vertices, and thus would like to index it. The docs suggest:

Most external indexing backends support ordering natively and efficiently. However, the property key used in the orderBy method must be configured to be indexed in this indexing backend for native result ordering support. This is important in cases where the orderBy key is different from the query keys. If the property key is not indexed, then sorting requires loading all results into memory.

Specifically for the Elasticsearch backend, how can we create an index that will support this orderBy method?

Is there a simple 3rd parameter to pass to the KeyMaker's indexed method, possibly an extension to the below example from the docs?

graph.makeKey("age").dataType(Integer.class).indexed("search", Vertex.class).make();
Était-ce utile?

La solution

You just need to index the property in ES (like any other property).

Indexed in Titan (wrong; orderBy will not be optimized):

graph.makeKey("age").dataType(Integer.class).indexed(Vertex.class).make();

Indexed in ES (correct; native result ordering in ES):

graph.makeKey("age").dataType(Integer.class).indexed("search", Vertex.class).make();

Cheeers, Daniel

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top