2
votes

Hi I am trying to write a query in Gremlin-Javascript to query AWS Neptune DB. During the query I want my anchor point to be case insensitive. I did like this:

[errRelatedTicket, relatedTicket] = await to(g.V().hasLabel('Anchor').or(hasId('anchorId'), hasId('ANCHORID'),hasId('anchorid')).in_('SOURCEDATA_HAS_ANCHORPOINT').in_('EVENT_HAS_SOURCEDATA').out('EVENT_HAS_CASE').dedup().toList());

But I got an error saying 'hasId not defined', I think there is something wrong with the 'or' step. I also tried it in neptune db console. Actually, it works using:

g.V().hasLabel('Anchor').or(hasId('anchorId'), hasId('ANCHORID')).in('SOURCEDATA_HAS_ANCHORPOINT').in('EVENT_HAS_SOURCEDATA').out('EVENT_HAS_CASE').dedup().toList()

did i miss anything?

1
I do see the definition of or step in gremlin-javascript lib ``` /** * Graph traversal or method. * @param {...Object} args * @returns {GraphTraversal} */ or(...args) { this.bytecode.addStep('or', args); return this; } . ``` - Hongli Bu

1 Answers

3
votes

You should import the graph traversal statics, and then use it to start inner traversals:

const __ = gremlin.process.statics;

g.V().hasLabel('Anchor')
  .or(__.hasId('anchorId'), __.hasId('ANCHORID'))
  .in('SOURCEDATA_HAS_ANCHORPOINT')
  .in('EVENT_HAS_SOURCEDATA')
  .out('EVENT_HAS_CASE').dedup().toList()