Hello,
Can you please confirm if my understanding below is correct? I think I managed to fix the error, but just want to double check here.
Yesterday I upgraded from version 4.2.4 to 4.3.2, and this morning I found a new message error on one of my cypher queries that updates my Neo4j database on a daily basis. After looking at the offending cypher code, I think I spotted where my mistake is.
This is my old cypher query:
MATCH(AllLaws)
WHERE (AllLaws:FirstLaw OR AllLaws:SecondLaw OR AllLaws:ThirdLaw OR AllLaws:FourthLaw)
AND AllLaws:NewLaws
WITH COLLECT( DISTINCT AllLaws.id_law ) AS lawids
MATCH(n)
WHERE(n:FirstLaw OR n:SecondLaw OR n:ThirdLaw OR n:FourthLaw)
AND n.id_law IN lawids AND NOT n:NewLaws
WITH n.id_law AS updatedlaws
MATCH(p)
WHERE(p:FirstLaw OR p:SecondLaw OR p:ThirdLaw OR p:FourthLaw)
AND p.id_law IN updatedlaws
SET p:UpdatedLaw
I've been executing this cypher query for about a month now, and it didn't generate any errors until this morning when it produced this message:
{code: Neo.ClientError.Statement.TypeError} {message: Expected list, got Long(1619)}
I believe the error says it all, no? My cypher query was expecting a list of values, but it instead was given a Long integer. The "Long" here is, I presume, a reference to the Java long data type which is the same as the Cypher integer data type.
To fix this query, I needed another collect function in the second match statement like this:
MATCH(AllLaws)
WHERE (AllLaws:FirstLaw OR AllLaws:SecondLaw OR AllLaws:ThirdLaw OR AllLaws:FourthLaw)
AND AllLaws:NewLaws
WITH COLLECT( DISTINCT AllLaws.id_law ) AS lawids
MATCH(n)
WHERE(n:FirstLaw OR n:SecondLaw OR n:ThirdLaw OR n:FourthLaw)
AND n.id_law IN lawids AND NOT n:NewLaws
WITH COLLECT( DISTINCT n.id_law ) AS updatedlaws
MATCH(p)
WHERE(p:FirstLaw OR p:SecondLaw OR p:ThirdLaw OR p:FourthLaw)
AND p.id_law IN updatedlaws
SET p:UpdatedLaw
What this query does is that it searches for only those Law nodes that has at least 2 different laws associated with the same law_id (any given law_id could have anywhere from 1 law to 4 laws), and it places an "UpdateLaw" label on those nodes where a law_id gained an additional law.
Thanks