I am using Amazon Neptune with Gremlin query language. I am trying to find out if a given vertex has any edge connected to it other than edges with a specific label.
For example, if there is a vertex with the label Person
and I want to find out if the vertex has any edge that has a label not equal to knows
.
I tried the following queries to get the result:
g.V(<id of person>).bothE().hasLabel(neq('knows')).count();
g.V(<id of person>).bothE().has(label, neq('knows')).count();
g.V(<id of person>).bothE().hasLabel(not(eq('knows'))).count();
g.V(<id of person>).bothE().hasLabel(eq('knows').negate()).count();
g.V(<id of person>).bothE().has(label, not(eq('knows'))).count();
g.V(<id of person>).bothE().hasLabel(without('knows')).count();
g.V(<id of person>).bothE().hasLabel(not(within('knows'))).count();
All of the queries above returned the following exception:
org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":"<id>","code":"UnsupportedOperationException",
"detailedMessage":"com.amazon.neptune.storage.volcano.ast.UnionNode cannot be cast to com.amazon.neptune.storage.volcano.ast.PatternNode"}
The issue seems to occur only when I am trying to use a "not equals" clause. If I change these conditions to "equals", it works fine. Also it happens only when I am trying this comparison on the label property while the edges are found using bothE()
function.
For instance, all of these queries work fine:
g.E().hasLabel(neq('knows')).count();
g.V(<id of person>).bothE().hasLabel(eq('knows')).count();
g.V(<id of person>).bothE().hasLabel(within('knows')).count();
If anybody knows why this happens or if anybody knows a work around for this situation, please let me know.
Please note: There are several edges that can be connected to the Person node. Hence it may be difficult to check if an edge with any of the possible remaining labels is connected to the vertex.
Thank you.
What about:
g.V(<id of person>).bothE().not(hasLabel('knows')).count()