Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-31-2022 12:22 AM
Hi!!
In my database, I have :TEAM nodes which have :MEMBERSHIP relationships with :PLAYER nodes.
:MEMBERSHIP relationships have isActive property which is a boolean indicating whether the player is active.
I'm using apoc.path.expand() to expand player nodes, but I need to expand filtering by this isActive property.
In the doc I can't find out how to filter by relationship properties, anyone who knows how, or any optimal solution?
Thank you in advance for your comments 🙂
Solved! Go to Solution.
08-31-2022 06:01 AM
I can think of two solutions. First, you could change your data model to use relationship types to indicate the active status of the membership, such as ACTIVE_MEMBERSHIP and INACTIVE_MEMBERSHIP. You can then use the relationship filtering in apoc.path.expand(). This may be good overall if you routinely search for either active or inactive relationships in your queries. If you have queries that done query, you will need to use ':ACTIVE_MEMBERSHIP|INACTIVE_MEMBERSHIP' as your relationship type in those queries.
The second option is to filter out those paths that don't meet your criteria after the apoc.path.expand() returns its results. Assuming 'path' represents the result, you can use a predicate like this to filter and return only the paths have isActive true for every relationship.
where all(i in relationships(path) where i.isActive)
08-31-2022 06:01 AM
I can think of two solutions. First, you could change your data model to use relationship types to indicate the active status of the membership, such as ACTIVE_MEMBERSHIP and INACTIVE_MEMBERSHIP. You can then use the relationship filtering in apoc.path.expand(). This may be good overall if you routinely search for either active or inactive relationships in your queries. If you have queries that done query, you will need to use ':ACTIVE_MEMBERSHIP|INACTIVE_MEMBERSHIP' as your relationship type in those queries.
The second option is to filter out those paths that don't meet your criteria after the apoc.path.expand() returns its results. Assuming 'path' represents the result, you can use a predicate like this to filter and return only the paths have isActive true for every relationship.
where all(i in relationships(path) where i.isActive)
All the sessions of the conference are now available online