How to filter by relationship name in neo4j with Condition

Viewed 46

I have some legacy code that filters neo4j nodes with Conditions:

private Condition addConditionIfExist(String fieldName,
                                      String fieldValue,
                                      String nodeLabel,
                                      Node mainNode,
                                      Condition currentCondition) {
    Node node = node(nodeLabel).withProperties(fieldName, Cypher.literalOf(fieldValue));
    Relationship link = mainNode.relationshipBetween(node);
    return currentCondition.and(link);

Now I need to add filtering by relationship name. I tried to add .withProperties("type", Cypher.literalOf("TYPE_NAME")) to link variable, but that does nothing. So, is there any way to add specific reltype to this condition?

1 Answers

So, it was a pretty simple solution

mainNode.relationshipBetween(node, "REL_TYPE")

You can just pass here a String label of type that you want

Related