I have this theoretical graph structure:
(:Car)<-[:LIKES_C]-(:Person)-[:LIKES_B]->(:Bike)
Person
also has other relationships not containing a word LIKES, say (:Person)-[:LOVES]-(:Person)
I'd like to write a cypher query which will yield all nodes connected to a Person
with a relation, which name starts with LIKES.
Also I cannot change relation names to LIKES
because there are lots of nodes with label Bike
and Car
and according to this post Neo4j will be inefficient in a query like:
MATCH (p:Person)-[:LIKES]->(:Car)
It will search through both Cars
and Bikes
and then filter for Cars
effectively increasing execution time.
Is there an efficient way to query for LIKES*
relationship?
:LIKES
relationship in addition to the specific:LIKES_*
relationships is the way to go. Won't a graph model aligned with the queries be more efficient, in general? – rickhg12hsdb.schema
clarity... – Jakub Licznerski