I don't know Neo4j really, but it looks somewhat similar to how it works with JanusGraph. You basically have to define a schema for JanusGraph which also contains your indices. If you want to use ElasticSearch as an index backend for a particular property, then you have to create a mixed index for that which uses ElasticSearch as the index backend.
For string based indices, you have to decide whether you want to do full-text search, string search or both. Full-text search means that your strings are tokenized which usually means that they are split into words. you can then search for individual tokens, or words. This makes sense if you want to index whole texts. String search on the other hand means that the strings are indexed as is which allows you to match on the whole string, opposed to just its words. Since first name and last name are probably mostly just single "words",
string search seems to be the better choice here. You can crate a schema for your
Person vertices like this:
mgmt = graph.openManagement()
person = mgmt.makeVertexLabel('Person').make()firstName = mgmt.makePropertyKey('first_name').dataType(String.class).make()lastName = mgmt.makePropertyKey('last_name').dataType(String.class).make()
mgmt.buildIndex('personsByFirstName', Vertex.class).addKey(firstName, Mapping.STRING.asParameter()).indexOnly
(person
).buildMixedIndex("search")
mgmt.buildIndex('personsByLastName', Vertex.class).addKey(lastName, Mapping.STRING.asParameter()).indexOnly(person).buildMixedIndex("search")
mgmt.commit()
This allows you to do traversals that search for examples for all persons whose first name begins with a certain string:
g.V().has('Person', 'first_name', textPrefix('nodech'))
or matches a certain regular expression:
g.V().has('Person', 'first_name', textRegex('.*ode.*')