Filter vertices using the “IN” operator

Can we pass the string “1,2,3,4” into a query as parameter and then filter for vertices with those primary IDs? If so, how?

I’m now using [WITH primary_id_as_attribute=“true”] hoping this will help.


such as:
Where id IN (myStringParam)

Thank you

To use the IN operator, the righthand operand needs to be a set.
“1,2,3,4” is not considered a set; it is just a string which happens to have commas in it.
GSQL syntax for an explicit set is parentheses on the outside and commas between elements.
So, for example, this is a set of strings:

I have not tested your exact situation, so I cannot say for certain whether you can give an inline definition of a set with the IN operation, or if you can use string ids.

Yes, we can do this though it requires a specific UDF to be available I think.
Let me have a look and see what the options are.

It is possible to add a SET as a literal in the parameter, and also a JSON string. Do you have control of the format of the parameter?

Yes I should have control of the format.