what language are you using?
besides cypher you can also look into a traversal/shortest-path starting at n1 and ending at n2 with a max_depth of 1.
But cypher should work fine.
Please be aware that if there is no relationship between the nodes an empty result will be returned.
Michael
For Gremlin and Cypher queries you can also use neo4jrestclient:
>>> from neo4jrestclient.client import GraphDatabase
>>> gdb = GraphDatabase("http://localhost:7474/db/data")
>>> query = """START n1=node(1), n2=node(2)
.. MATCH n1-[:KNOWS]->n2
.. RETURN count(*)"""
>>> cypher = gdb.extensions.CypherPlugin.execute_query
>>> relationships = cypher(query=query)
Or the same using Gremlin:
>>> script = "g.v(1).bothE().filter{it.outVertex == g.v(2) || it.inVertex == g.v(2)}"
>>> gremlin = gdb.extensions.GremlinPlugin.execute_script
>>> relationships = gremlin(script=script)
Or just returning the data as raw:
>>> relationships = gremlin(script=script, returns=client.constants.RAW)
And another less efficient way is just a comprehesion list like this one:
>>> relationships = [r for r in n2.relationships.all(type=["KNOWS"]).all() if n2 == r.end]
Best regards.
>
>
> On 22 April 2012 22:58, Michael Hunger <michael...@neotechnology.com>
> wrote:
>>
>> Martin,
>>
>> what language are you using?
>>
>> besides cypher you can also look into a traversal/shortest-path starting
>> at n1 and ending at n2 with a max_depth of 1.
>>
>> But cypher should work fine.
>>
>> Please be aware that if there is no relationship between the nodes an
>> empty result will be returned.
>>
>> Michael
>>
>> Am 22.04.2012 um 23:27 schrieb Martyzz1:
>>
>> > I would like to run Cypher queries against neo4j via a REST client....
>> > Can anybody recommend a client?
>> >
>> > Or
>> >
>> > alternatively, is there a way using the REST api to check if a
>> > Relationship between 2 nodes exists?
>> >
>> > e.g. do this through the rest interface only?
>> > START n1=node(1), n2=node(2)
>> > MATCH n1-[:KNOWS]->n2
>> > RETURN count(*)
>> >
>> > Regards
>> >
>> > Martin
>>
>
--
Javier de la Rosa
http://versae.es
Thanks everyone. I'm expecting hundreds of thousands of relationships... On both nodes.. would this have an impact?
Ok great. This then puts me back to the situation of retrieving a relationship by the results of the cypher query, so I can delete it, or update its properties.....
That's the bit I'm stuck on in py2neo..
That's awesome! I'll check it out tonight and let you know how it goes.. thanks everyone.