0

I am trying to query using Neo4j. I would like to print result of obtaining information while AUTO-COMPLETE is ON in Neo4j. For example, suppose query that creating 3 nodes as shown below.

create (david:Person {name: 'david'}), (mike:Person {name: 'mike'}), (book:Book {title:'book'}), (david)-[:KNOWS]->(mike), (david)-[:WRITE]->(book), (mike)-[:WRITE]->(book)

Here are 2 images:

  • Auto-complete on

  • Auto-complete off

Figure is shown after query, and I would like to obtain all relating node’s relationships based on starting node ('book' node). I used this query as shown below.

match (book:Book)-[r]-(person) return book, r, person

Whether AUTO-COMPLETE is ON or OFF, I expect to obtain all node’s relationships including “David knows Mike”, but system says otherwise.

I studied a lot of Syntax structure at neo4j website, and somehow it is very difficult for me. So, I upload this post to acquire assistance for you.

Frank Pavageau
  • 11,477
  • 1
  • 43
  • 53
ys you
  • 9
  • 3
  • neo4j website is https://neo4j.com/docs/cypher-refcard/current – ys you Dec 21 '16 at 07:47
  • Possible duplicate of [Replicate Neo4j browser auto-complete function in a cypher statement](http://stackoverflow.com/questions/31029276/replicate-neo4j-browser-auto-complete-function-in-a-cypher-statement) – InverseFalcon Dec 21 '16 at 08:42

2 Answers2

0

You have to return all the data that you need yourself explicitly. It would be bad for Neo4j to automatically return all the relationships for a super node with thousands of relationships for example, as it would mean lots of I/O, possibly for nothing.

MATCH (book:Book)-[r]-(person)-[r2]-()
RETURN book, r, person, collect(r2) AS r2
Frank Pavageau
  • 11,477
  • 1
  • 43
  • 53
  • Thank you for your reply. Unfortunately, this is not the answer that I am looking for. The answer that InverseFalcon provided is the one that I am looking for, but I appreciate your support. – ys you Dec 22 '16 at 11:20
0

Thanks to InverseFalcon, this is my query that works.

MATCH p = (book:Book)-[r]-(person:Person) 
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 
WITH DISTINCT r2 
RETURN startNode(r2), r2, endNode(r2)
InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
ys you
  • 9
  • 3