简体   繁体   中英

Gremlin Tinkerpop get vertex with partial ID

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM