Search code examples
gremlinamazon-neptune

Gremlin: Performing Text Search in AWS Neptune


Using Gremlin how can I perform Text search like,

- Name starts with "A"
- Name ends with "B"
- Name contains "t"
- etc.

I know NEO4J and Janus have some custom code for such a thing.

I figured out Neptune does not support Regex. https://forums.aws.amazon.com/thread.jspa?messageID=854392󐥸


Solution

  • I think that the only option at this point is support for startsWith() like functionality as in:

    gremlin> g = TinkerFactory.createModern().traversal()
    ==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
    gremlin> g.V().has('name',between('m','n'))
    ==>v[1]
    

    The rest is just not possible with Neptune at this time - more discussion on this topic is present on this other question.

    UPDATE: As of TinkerPop 3.6.0, Gremlin now has a TextP.regex predicate that can help with these sorts of searches:

    gremlin> g.V().has('name', TextP.regex('m.*o')).elementMap()
    ==>[id:1,label:person,name:marko,age:29]
    

    You may read more about it in the Upgrade Documentation.