Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-19-2020 10:15 AM
I'm trying to wrangle some data here. I've got a relationship set up that looks like:
(:Well {lastProdDate: Date})-[:ON]->(:Abstract {name: Name})
I'm trying to single out abstracts that have wells where 100% of the production is earlier than a certain date. So far I've got:
WITH DATE("2019-01-01") as endDate
MATCH (w:Well)-[:ON]->(a:Abstract)
With Collect(w.lastProdDate) as dates
After that I need to loop through the dates and return only abstracts where all dates are less than endDate. Any one done anything similar?
Solved! Go to Solution.
01-19-2020 03:09 PM
MATCH (a:Abstract {name: Name})
WHERE ALL( w IN [(w)-[:ON]->(a) | w] WHERE w.lastProdDate > $date)
RETURN a
or
MATCH (a:Abstract {name: Name})
WHERE size( ()-[:ON]->(a)) = size[(w)-[:ON]->(a) WHERE w.lastProdDate > $date | w])
RETURN a
01-19-2020 02:54 PM
WITH DATE("2019-01-01") as endDate
MATCH (w:Well)-[:ON]->(a:Abstract)
WHERE w.lastProdDate <= endDate
With Collect(w.lastProdDate) as dates
Without WITH,
WHERE w.lastProdDate <= "2019-01-01"
01-19-2020 03:03 PM
That's not quite it, it does indeed return a collection of the dates that match that criteria but it doesn't return only the collections where all pass. You've got me closer though, thank you!
01-19-2020 03:09 PM
MATCH (a:Abstract {name: Name})
WHERE ALL( w IN [(w)-[:ON]->(a) | w] WHERE w.lastProdDate > $date)
RETURN a
or
MATCH (a:Abstract {name: Name})
WHERE size( ()-[:ON]->(a)) = size[(w)-[:ON]->(a) WHERE w.lastProdDate > $date | w])
RETURN a
All the sessions of the conference are now available online