Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-16-2018 10:29 AM
Why do the following two queries produce different results with respect to the actor's names? In the second one I am just collecting all the movie titles and for some reason, the actor names change.
match (keanu:Person{name:"Keanu Reeves"})-[:ACTED_IN]->()<-[:ACTED_IN]-(c),
(c)-[:ACTED_IN]->(m)<-[:ACTED_IN]-(others)
where others <> keanu and not ((others)-[:ACTED_IN]->()<-[:ACTED_IN]-(keanu))
return distinct others.name
limit 5
vs
match (keanu:Person{name:"Keanu Reeves"})-[:ACTED_IN]->()<-[:ACTED_IN]-(c),
(c)-[:ACTED_IN]->(m)<-[:ACTED_IN]-(others)
where others <> keanu and not ((others)-[:ACTED_IN]->()<-[:ACTED_IN]-(keanu))
return distinct others.name, collect(m.title)
limit 5
Solved! Go to Solution.
09-16-2018 06:58 PM
You're using LIMIT, but not ORDER BY. When no ORDER BY is present the query planner has no restrictions on operations that change the order. Looks like the collecting of movie titles altered the order here, and so your LIMIT got you a different set of results from the results stream.
Use ORDER BY if it's important that your LIMIT gets you to the same set of people between the two queries.
09-16-2018 06:58 PM
You're using LIMIT, but not ORDER BY. When no ORDER BY is present the query planner has no restrictions on operations that change the order. Looks like the collecting of movie titles altered the order here, and so your LIMIT got you a different set of results from the results stream.
Use ORDER BY if it's important that your LIMIT gets you to the same set of people between the two queries.
All the sessions of the conference are now available online