bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.33k stars 148 forks source link

"ERROR: graph object cannot be jsonb" when filtering by multiple IDs #512

Closed berinhard closed 4 years ago

berinhard commented 4 years ago

Hi, first of all, thanks for all of your good work developing and maintaining AgensGraph! I'm having a problem and I hope you can help me to understand why it's happening.

I'm trying to run a simle Cypher query to filter my nodes by a set of IDs instead of a single one, but I'm getting the error ERROR: graph object cannot be jsonb. I'm using the same Cypher query as described in this Stackoverflow's answer.

Here's an example of what I'm executing:

agens=# MATCH (node) WHERE ID(node) IN [4.8741916, 5.1238233, 4.9477445] RETURN node;
ERROR:  graph object cannot be jsonb
LINE 1: MATCH (node) WHERE ID(node) IN [4.8741916, 5.1238233, 4.9477...
                              ^
agens=# MATCH (node) WHERE ID(node) = 4.8741916 RETURN node;
                                      node                                       
---------------------------------------------------------------------------------
 person[4.8741916]{"name": "JARI ***** ***** *****", "document": "***648***"}
(1 row)

I think the issue happens when I combine the IN keyword with the ID function, because when I use it with a node property, it works as expected:

agens=# MATCH (node) WHERE node.name IN ['JARI FRANCISCO DE ASEVEDO', 'JAIR MESSIAS BOLSONARO'] RETURN COUNT(*);
 count 
-------
 2
(1 row)
berinhard commented 4 years ago

After keep on researching on how to perform this query, I realized I had to convert ID(node) to a jsonb object. In the end, the working query is:

agens=# MATCH (node) WHERE ID(node)::jsonb IN ['4.8741916', '5.1238233', '4.9477445'] RETURN COUNT(*);
 count 
-------
 3
(1 row)