Match on multiple types


I don’t think the following is allowed:

“MATCH (a: A)-[:E1|E2]->(b: B)”.

Can you suggest a workaround or if I’m mistaken?

Maybe ‘MATCH path=(a: A)–>[b: B] WHERE all(e in edges(path) WHERE type(e) == “E1” OR type(e) == “E2”’?

I have a feeling this wouldn’t be too performant. Can you suggest what I should do?

@dsolnik The first query you suggested should be fine! I now realize this is not in our documentation, which we’ll have to update soon, but RedisGraph does support label disjunction.

Is there any better syntax than what I’ve mentioned here?

Thank you for all your help!

No, that syntax is fine!

Internally, RedisGraph will add the two adjacency matrices for E1 and E2 before performing traversals, so traversing multiple edge types this way shouldn’t even incur too much of a performance hit.

I would suggest E1 I think there is more value on path

I just realized that I might have misunderstood your response. Are we referring to the syntax using the | or using the “all”? The “|” syntax is supported?

I will make a pr editing to the docs on Monday to include an answer to this question.

Ah, sorry! The pipe syntax is supported, so you can traverse edge types of either E1 or E2 with the query:
“MATCH (a: A)-[:E1|E2]->(b: B)”
As you originally hoped.

1 Like