Searching against an external index
The following query will use the Elasticsearch backend:
g.query().has('my_label',CONTAINS,'abc').edges()
In general, any has
query that contains three arguments will use your external index backend (Elasticsearch or Lucene).
The following query would perform an exact match instead:
g.query().has('my_label','abc').edges()
Getting your property key into the external index
graph.makeType().name("my_label").dataType(String.class).indexed("elastic", Vertex.class).unique(Direction.OUT).makePropertyKey();
The key difference between adding a Titan native index and an external index is the second parameter in the indexed(..)
call which indicates the name of the external index in which your property should be indexed.
Unfortunately right now, once a property exists with a certain key, you cannot add an index on that key; you would have to start with a fresh graph.
More information
The Titan docs are pretty easy to read:
https://github.com/thinkaurelius/titan/wiki/Indexing-Backend-Overview
(Bonus: Titan is being expanded to include other types of partial searching including prefix and regexp: https://github.com/thinkaurelius/titan/pull/311)