Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-06-2022 12:18 AM
Hi everyone,
I wanted to write a small query that gives me a list of nodes that don't have a specific relationship.
A quick google gives me results that suggest this solution:
match (p:Product)
where not (p)-[:HAS_CATEGORY]->(:Category)
return count(p)
This works and is simple enough, but it keeps giving me this warning:
This feature is deprecated and will be removed in future versions.
Coercion of list to boolean is deprecated. Please consider using 'NOT isEmpty(...)' instead.
I have been googling this warning but it leads me to no conclusion as to how my original query should be written.
In general I found it quite frustrating to find an answer, which is also the reason I came to the forum.
Either I do not know the right place to find these kind of things or either the documentation regarding these warnings is extremely lacking.
Thanks for reading this,
Jimmy
04-06-2022 01:47 AM
Hello @jim.ruts
I know this one works:
MATCH (p:Product)
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)
Could you also try:
MATCH (p:Product)
WHERE isEmpty((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)
Regards,
Cobra
04-06-2022 02:07 AM
Hi cobra,
both solutions work, but they give the exact same warning regarding the coercion 😞
04-06-2022 02:18 AM
Which version of Neo4j and Neo4j Browser are you using?
I don't get any warnings on my side for the query with exists
but I get one with the isEmpty
witch recommend to use exists
04-06-2022 02:25 AM
I am using Aura, which is using neo version 4.
I refactored my query to this:
match (p:Product)
with
p,
exists((p)-[:HAS_CATEGORY]->(:Category)) as x,
where x = false
return count(p)
This removed all warning but this looks like such a nasty query for something so simple
04-06-2022 02:26 AM
I'm not aware of the deprecation of exists()
function so you can stick with this:
MATCH (p:Product)
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)
04-06-2022 02:27 AM
Refreshing the neo browser stopped giving the warning for the exists example
MATCH (p:Product)
WHERE NOT exists((p)-[:HAS_CATEGORY]->(:Category))
RETURN count(p)
riddle me that -_-
It also stopped giving me warning on my original example.
04-06-2022 02:29 AM
On my test environment aura instance it does keep giving me warnings for both examples....
On my dev environment aura instance it does not....
04-06-2022 02:39 AM
Well, I guess you should report that, must be a bug.
All the sessions of the conference are now available online