Search code examples
gremlintinkerpopamazon-neptune

How to select multiple ids with Gremlin?


In the console, this returns two vertices:

g.V('615e6de7-3172-458b-bc68-876fd4f5ecb0','059b6de4-a463-4789-a987-7c2833950b5c')
==>v[615e6de7-3172-458b-bc68-876fd4f5ecb0]
==>v[059b6de4-a463-4789-a987-7c2833950b5c]

But when I run it in Gremlin, I get no results:

const idList = `"615e6de7-3172-458b-bc68-876fd4f5ecb0","059b6de4-a463-4789-a987-7c2833950b5c"`;
let traversal = await g.V(idList).toList();

I can get each id individually, but what is the syntax to fetch multiple ids in a single traversal?


Solution

  • The issue in your code is, you are trying to send a string with comma separated ids. Instead you have to send an array of ids.

    const ids = ['3994', '3997'];
    g.V(ids).properties()