[Neo] Checking whether a relationship exists between two nodes...

Rick Bullotta rick.bullotta at burningskysoftware.com
Wed Feb 3 00:13:46 CET 2010


Yes, you're right.  Our domain model lets us get away with the "one way"
check!

I agree that it would be a very useful and valuable capability for Neo4J,
though.  It shouldn't require an external index, for sure.  It should be
something "native".

-----Original Message-----
From: user-bounces at lists.neo4j.org [mailto:user-bounces at lists.neo4j.org] On
Behalf Of Raul Raja Martinez
Sent: Tuesday, February 02, 2010 5:53 PM
To: Neo user discussions
Subject: Re: [Neo] Checking whether a relationship exists between two
nodes...

Hi Rick,

AFAIK the current hasRelationship methods don't let you check for the
second node.
We notice this same issue when we first start coding with Neo, seems
natural to have that kind of API where you check wether a node has a
certain relationship to a another node.
Not sure how expensive would be to keep track of though.

2010/2/2 Rick Bullotta <rick.bullotta at burningskysoftware.com>:
> Hi, Maria.
>
> You should be using the hasRelationship(...) method of the Node object.
>
> http://api.neo4j.org/current/org/neo4j/graphdb/Node.html
>
> Best regards,
>
> Rick
>
> -----Original Message-----
> From: user-bounces at lists.neo4j.org [mailto:user-bounces at lists.neo4j.org]
On
> Behalf Of Maria Giatsoglou
> Sent: Tuesday, February 02, 2010 5:45 PM
> To: user at lists.neo4j.org
> Subject: [Neo] Checking whether a relationship exists between two nodes...
>
> Hello all
>
> I am creating a project that performs a number of benchmark tasks on Neo.
> One of the tests measures the required time for creating a relationship
> between two neo nodes A and B.
> However, before creating the relationship, it should firs be checked
> whether a relationship of the same type already exists
> between these two nodes. My current implementation calls the
> getRelationships() function
> for the A node and then iterates over the returned Iterable object
> checking whether a relationship's end node is equal to node B.  If  such
> a relationship does not exist, then the required relationship is created
> between nodes A and B.
>
> However, this technique seems to be very slow, with the creation of a
> relationship (including the check operation)  taking around 57msec to
> complete. Is there a faster way to implement this operation? I
> considered trying to modify the LuceneIndexService implementation in
> order to enable indexing
> relationships apart from nodes. Do you recommend such an approach for
> this problem?
>
> Many thanks in advance,
>
> Best regards,
>
> Maria Giatsoglou
> _______________________________________________
> Neo mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
> _______________________________________________
> Neo mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Raul Raja
_______________________________________________
Neo mailing list
User at lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user



More information about the User mailing list