for (Relationship r : n.getRelationships(dir, type)) 
  if (r.getOtherNode(n).equals(m)) return true;


Sent from mobile device

Am 06.07.2014 um 17:09 schrieb Frandro <[email protected]>:

> I'm running embedded. How'd the code for core API be like?
> 
> 2014년 7월 6일 일요일 오후 11시 28분 49초 UTC+9, Michael Hunger 님의 말:
>> 
>> If you're running embedded anyway, then I'd use core API for this check, not 
>> cypher
>> 
>> If you use cypher
>> 
>> - use parameters
>> - use match not where
>> 
>>> START n1=node({id1}), n2=node({id2})
>>> match (n1)-[:%s]-(n2)
>>> RETURN true
>> Limit 1
>> 
>> Or rather for 2.x
>> 
>>> match (n1)-[:%s]-(n2)
>> Where id(n1)={id1} and id(n2)={id2}
>>> RETURN true
>> Limit 1
>> 
>> Sent from mobile device
>> 
>> Am 06.07.2014 um 11:37 schrieb Frandro <[email protected]>:
>> 
>>> The following query is that I use to check existence of an edge between the 
>>> two nodes, n1 and n2.
>>> 
>>> It seems the query costs a lot.
>>> 
>>> Is this optimized or not? Is there a better way to find it out?
>>> 
>>> String query = String.format("START n1=node(%d), n2=node(%d) WHERE 
>>> n1-[:%s]-n2 RETURN count(*) as count_edges", nodeId1, nodeId2, edgeType);
>>> 
>>> 
>>> ExecutionResult result = engine.execute(queryString);
>>> int countEdges = 
>>> Integer.valueOf(result.columnAs("count_edges").next().toString());
>>>         
>>> if (countEdges > 0)
>>>   return true;
>>>                 
>>> return false;
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Neo4j" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to