β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