3

I am trying to replicate the "auto-complete" functionality of the neo4j browser interface using only a cypher query. A successful implementation would mean that if the query is executed in the browser, toggling the auto-complete button would have no effect, as all "additional relationships" are specified in the query.

I use the browser to prototype the queries, then use RNeo4j to implement them. Ideally, I'd like the RNeo4j result to match the browser result including auto-complete.

As an example, consider the query:

`MATCH p = (n:label1 {name:'tom'})-[r*2..3]-(n:label1 {name:'jerry'})
RETURN p`

In the browser, with auto-complete turned off, I only get what I asked for (as expected), whereas when auto-complete is turned on, I get all relationships between any nodes on the path where neither node is "tom" or "jerry".

I have tried using WITH followed by a second MATCH following the first MATCH but this does not yield the results I require.

Any help greatly appreciated!

ArminD
  • 33
  • 5

1 Answers1

7

the autocomplete feature makes another call to get the relationships between all the node ids it currently has

match a-[r]-b where id(a) in [1,2...] and id(b) in [1,2,3...] return r
cechode
  • 1,002
  • 1
  • 8
  • 20
  • 3
    Great, this works perfectly. Just to complete my example above, here is what I did: `MATCH p = (n:label1 {name:'tom'})-[r*2..3]-(n:label1 {name:'jerry'}) UNWIND nodes(p) as allnodes WITH COLLECT(ID(allnodes)) AS ALLID MATCH (a)-[r2]-(b) where ID(a) IN ALLID AND ID(b) IN ALLID RETURN rx` Now the cypher query returns the same result as the browser auto-complete – ArminD Jun 25 '15 at 07:29