-1

I have a Knowledge Graph database and I need to query it using Gremlin to get all connected nodes(Incoming + Outgoing) for a given Node. Right now I am using an approach where I query it twice to get Incoming and Outgoing connections. For outgoing connections, I am using -

"g.V().has('primaryName', 'NAME_OF_NODE').inE().outV().values('primaryName')"

For Incoming connections, I am using -

"g.V().has('primaryName', 'NAME_OF_NODE').outE().inV().values('primaryName')"

As of now I am running these as separate queries, is there any way to combine these two queries in a single query to save execution time.

David Makogon
  • 69,407
  • 21
  • 141
  • 189

1 Answers1

0

You can use bothE instead.

g.V().has('primaryName','NAME_OF_NODE').
      bothE().
      otherV().
      values('primaryName')
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38