Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-27-2022 12:23 AM
Greetings dear community,
I would like to ask about how I can get relations of nodes found by means of a full text query, here is how my query looks like:
06-27-2022 01:32 AM
You could use a ‘case’ statement in the ‘return’ clause to conditionally return one or the other properties based on the labels.
06-27-2022 02:33 AM
Thank you @glilienfield
But, in my case in want to return related nodes not properties, based on the label of course. Is there a way to achieve that?
06-27-2022 05:04 AM
Sorry for my misunderstanding. A simple approach would be to add an ‘option match’ for both relationship regardless of node type. You will get null results for the match that has no result. This would be ok if the optional match results are mutually exclusive, returning only on result for each node type.
another approach is to use one of the APOC library’s conditional procedures, which allow you to conditionally execute cypher queries. In your case the ‘case’ procedure seems appropriate. Your conditions would be the node labels, and the queries would be the match to get the relationships.
https://neo4j.com/labs/apoc/4.1/overview/apoc/apoc.case/
You can also use a ‘call’ subquery in a certain way to conditionally execute a block of cypher, but I don’t think this is applicable since you are returning data,
All the sessions of the conference are now available online