Get Nodes, Relationship depending on attributes on different relationship types in combination

Dear community,

I got nodes and relationships types from this structure:

class Ages(StructuredRel):
    age_score = IntegerProperty()

class Sizes(StructuredRel):
    size_score = IntegerProperty()


class Sample(StructuredNode):
    name = StringProperty()


    similarity_age= Relationship('Sample', "Ages", model=Ages)
    similarity_size = Relationship('Sample', "Sizes", model=Sizes)

Now I want to use a cypher query to return all nodes and relationships with the following condition:

I want to get:

  • all edges with an age_score >= 50 (their will be just one relationship of this type "Ages")

together with:

  • all edges between 2 nodes with size_score <= 40 (type " Sizes") , if the one existing edge (mentioned above) with age_score is >= 40
    (and I want to do that for all node pairs

example:

Sample1 ----- age_score = 60 -----> Sample2
Sample1 ----- size_score = 10 -----> Sample2
Sample1 ----- size_score = 70 -----> Sample2

Sample2 ----- age_score = 30 -----> Sample3
Sample2 ----- size_score = 30-----> Sample3
Sample2 ----- size_score = 80 -----> Sample3

Output should be:

Sample1 ----- age_score = 60 -----> Sample2 (conditon 1)
Sample1 ----- size_score = 10 -----> Sample2 (conditon 2)

Which query should I use?
I tried

MATCH (p:Sample)-[r1: Ages | r2: Sizes]->(c:Sample)
WHERE
(r1.age_score >= 50) or
(r2.size_score <= 40 and r1.age_score >= 40)
RETURN p, r1, r2, c

Hi!

If you change your query to the following, does it work as expected?

MATCH (p:Sample)-[r1: Ages|Sizes]->(c:Sample)
WHERE
(r1.age_score >= 50) or
(r1.size_score <= 40 and r1.age_score >= 40)
RETURN p, r1, c