In Neo4j, I need to find all relationships with a given property value, independently on the relationship type:
WITH ["1651365", "1188654", "1151147", ...] AS relIds
MATCH ()-[r]->() WHERE r.myId IN relIds
RETURN r.type AS type, properties ( r ) AS props;
This query works, but it’s very slow. If I profile it, I see it’s based on a full scan (of 14M relationships).
The problem is there is no way to define an index on all the relationship type (I can do the same with a list of types and the engine will use indexes defined for myId
).
Is there a solution? When using elementId()
, the engine does a seek operation and it’s very fast, but the documentation discourages it (they say internal IDs are reused after deletion).