Hi there,

Answers inline.

On Wed, Sep 21, 2011 at 4:49 AM, iamyuanlong <yuanlong1...@gmail.com> wrote:

> hi Peter,
>   This can get the result.But if I want to contain B's Friends too.Should I
> use this?
>
> http://neo4j-community-discussions.438527.n3.nabble.com/file/n3354221/follow%26friend.jpg
> Use:
> START b=(node_auto_index,'name:B') MATCH a-[:FOLLOW]->b-[:FOLLOW]->a or
> a-[:FRIEND]->b-[:FRIEND]->a  RETURN a
>

Unfortunately, OR is not something you can use in the MATCH clause - it's
strictly a WHERE animal. So, this doesn't work. Sorry.


>
> OR:
> START b=(node_auto_index,'name:B') MATCH a-[r]->b-[r]->a  RETURN  where
> r.TYPE="FOLLOW" or r.TYPE="FRIEND" a
>

This has another problem - you are re-using the 'r'-symbol twice, and that's
a no-no. What you can do is

START b=(node_auto_index,'name:B')
MATCH a-[r1]->b-[r2]->a
WHERE (type(r1) ="FOLLOW" or type(r2) = "FRIEND") AND (type(r2) = "FOLLOW"
or type(r2)="FRIEND")
RETURN  a

This last query doesn't make me very happy - it's far to verbose.

We've thrown around the idea of introducing a limited OR in the match,
something like this:

MATCH a-[:FOLLOW|FRIEND ]->b

WDYT? Would that be helpful, or is it just confusing?

HTH,

Andrés
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to