The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Message from discussion How to query nodes with multiple relationships?

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Aug 10 2012, 12:59 pm
From: "fli.rpx" <fudon...@gmail.com>
Date: Fri, 10 Aug 2012 09:59:48 -0700 (PDT)
Local: Fri, Aug 10 2012 12:59 pm
Subject: Re: [Neo4j] How to query nodes with multiple relationships?

Hi Michael,

There are differences between the two queries. The first query, "start
a=node(1405) match a-[:A*1..3]->m, a-[:B*1..3]->m return distinct m.name",
has AND relationship. Its result set will be the intersection of two
traversals.

The second query, "start a=node(1405) match a-[:A|B*1..3] return distinct
m; ", is OR relationship.

These two queries have performance difference. The first one will take two
traversals then compare. The second one only has one traversal.

I am wondering if I can write the first query in a way of the second query.
Something like this?:

start a=node(1405) match a-[:A&B*1..3] return distinct m;

Thanks,

Fudong

On Thursday, August 9, 2012 2:16:52 PM UTC-7, Michael Hunger wrote:

> I don't really understand your question?

> Does the second query not work for you?

> Michael

> Am 09.08.2012 um 21:48 schrieb fli.rpx:

> > I am trying to write a query to return nodes with two relationships.

> > One way to do it: start a=node(1405) match a-[:A*1..3]->m,
> a-[:B*1..3]->m return distinct m.name;

> > This will work, but takes much a lot more time than a query like this:
> start a=node(1405) match a-[:A|B*1..3] return distinct m;

> > I think maybe neo4j does two traversals in the first query.
> yes it does and their results span up a cross product which is filtered
> down by distinct again.

> > Is it possible to do a query to get nodes with both relationships like
> the second query?