Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-15-2022 01:44 AM
MATCH p=(f:Company)-[r:HAS_INVOICE*1..10]->(t:Company)
RETURN p;
MATCH p=(f:Company)-[r:HAS_INVOICE*1..10]->(t:Company)
WHERE NOT (f)-[:HAS_INVOICE {invoiceState = 'PAID'}]->(t)
RETURN p;
Invalid input '[': expected "+" or "-" (line 2, column 15 (offset: 70))
"WHERE NOT (f)-[:HAS_INVOICE {invoiceState = 'PAID'}]->(t)"
^
This query is working fine but I'm not able to retrieve the longestpath
MATCH p=(f:Company)-[r:HAS_INVOICE]->(t:Company)
WHERE
r.invoiceState in ['DUE', 'OVERDUE']
RETURN p;
Thanks for your help
Rinaldo
09-15-2022 02:47 AM
Hi @rinaldo_bonazzo 😄
You should use a predicate function
MATCH p=(f:Company)-[:HAS_INVOICE*1..10]->(t:Company)
WHERE all(r IN relationships(p) WHERE r.invoiceState in ['DUE', 'OVERDUE'])
RETURN p;
Regards,
Cobra
09-15-2022 03:01 AM - edited 09-15-2022 03:04 AM
The error is a result of the equal sign. The correct syntax is the following, which will restrict to a relationship the that property value.
[:HAS_INVOICE{invoiceState: ‘Paid’}]
you can find the longest path by sorting on the path length and returning the longest. Add the following after your ‘RETURN p’ statement:
ORDER BY length(p) DESC
LIMIT 1
the above solution assumes there is only one longest path, or you just one of the longest at random if there are more than one. I can provide a different solution when there could be multiple, but it seems that should not occur in your case.
All the sessions of the conference are now available online