Lookup relationship withe its Type

71 views
Skip to first unread message

Mahdi Negahi

unread,
Apr 8, 2012, 10:59:19 PM4/8/12
to Neo4j
Dear Friend

In my graph database I have a specific relationship's type that it
calls REFER. I want to write a Query that return all node which REFER
is its outgoing relationship.

please advice me.

Luanne Coutinho

unread,
Apr 8, 2012, 11:51:37 PM4/8/12
to ne...@googlegroups.com

Mahdi Negahi

unread,
Apr 9, 2012, 12:30:30 AM4/9/12
to Neo4j
i don't think so this is my answer because in this example query know
what is the start node. i don't know what the start node is.

I only know there are several relationship that its type is REFER. So,
I want to extract all outgoing node of these type of relationships

On Apr 8, 11:51 pm, Luanne Coutinho <luanne.couti...@gmail.com> wrote:
> Hi,
>
> Have you seenhttp://docs.neo4j.org/chunked/milestone/query-match.html#match-match-...

Luanne Coutinho

unread,
Apr 9, 2012, 12:47:47 AM4/9/12
to ne...@googlegroups.com
You could set your start to all nodes:
start n=node(*)

but honestly that may not really be the most efficient. Are your nodes not linked to some known starting point, even indirectly?

Maybe you can share your use case in more detail?

Emil Dombagolla

unread,
Apr 9, 2012, 12:52:38 AM4/9/12
to ne...@googlegroups.com
Hi ,

at least if you have reference ( Starting node for the graph /root node )node for your database , then you can query relationships matching to your type until end of the graph. you can index the nodes to take as a staring node for your query.

Hope this give you some idea.
thushanga.
--
Emil Dombagolla,




Mahdi Negahi

unread,
Apr 9, 2012, 1:29:06 AM4/9/12
to Neo4j
Thanks for your replies.

I have reference node in my graph database. in addition, it is related
to purpose node indirectly.

(n0) --> (n1) -->...-> (n) -[REFER]-> (n+1)

(n+1) is my desire node that i want to find it, but in my database
this kind of node is more than 1. I think the best way to index these
nodes.

Michael Hunger

unread,
Apr 9, 2012, 6:05:34 AM4/9/12
to ne...@googlegroups.com
start start=node(0) match start-[*]->()-[:REFER]->end return end

Depending on the size of your graph
start n=node(*) match ()-[:REFER]->n return n

Or you index the nodes or the REFER rels and look them up in the index.

Sent from mobile device

Reply all
Reply to author
Forward
0 new messages