Is there a way to get a vertex with only a partial ID? For example, let's say I have two unique values that make up part of the ID, such as: employeeName/{employeeName}/dob/{employeeDoB}
.
If I only have ONE of the values, such as employeeName
, can I still get the vertex by just knowing that part?
I was thinking I could use the Tinkerpop Text
enum and do something like:
g.V("employeeName/" + id, Text.startingWith);
But I get a serialization error with that:
- it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.io.IOException: Serializer for type org.apache.tinkerpop.gremlin.process.traversal.Text$3 not found
Using Tinkerpop 3.5.1 with Amazon Neptune.
You need to use TextP
and not Text
, and you also need to add a filtering step. So it becomes:
g.V().hasId(TextP.startingWith("employeeName/" + name));
This assumes you are sending the request from Java. In a large graph this may not be efficient, and you may want to consider looking at the OpenSearch/ElasticSearch Full Text Search (FTS) integration.