Improve the use of lists stored as property
Cobra5197 opened this issue · comments
Hi,
I have lists of integers stored as a property in my database management system but I can not do anything with them in Cypher. For example, with UNWIND
or the function toIntegerList()
, I get this error: Expected a List, got: LongArray[2339, 2880]
.
I was told to use the APOC function apoc.convert.toIntList()
to be able to work with my property. So I tried to overwrite my property with the converted list to avoid converting it every time I need to use it: SET r.prds = apoc.convert.toIntList(r.prds)
. Unfortunately I was surprised to see that my list had the same type i.e. LongArray
.
Would it be possible to be able to store a list of integers or ensure that the property is converted to a list of integers when the property is loaded into the database in order to avoid converting every time the property as soon as I need it in a Cypher request?
Best Regards,
Maxime
Hello Maxime.
Could you clarify?
The following works (Neo4j 4.3)
create (a:N {p: [2339, 2880]})
with a
unwind a.p as v
return v;
+------+
| v |
+------+
| 2339 |
| 2880 |
+------+
neo4j@neo4j> create (a:N {p: [2339, 2880]})
with a return apoc.convert.toIntList(a.p);
+-----------------------------+
| apoc.convert.toIntList(a.p) |
+-----------------------------+
| [2339, 2880] |
+-----------------------------+
Type of the property as expected:
neo4j@neo4j> match (a:N) return apoc.meta.type(a.p);
+---------------------+
| apoc.meta.type(a.p) |
+---------------------+
| "long[]" |
| "long[]" |
+---------------------+
As you specifically asks with APOC and specific Neo4j functions, I assume you are using Neo4j and not another product; meaning the issue is actually openCypher related and not a vendor specific problem.
I was developing the query with the Neo4j browser. I feel like I'm crazy because there seems to be no problem now. I was on Neo4j 4.4.2 when this issue occurred. I can't reproduce the error anymore.
Hehe, I know that feels, happens to most of us.
If there isn’t anything to help you on this, we would rather close this issue.