I am getting started with Neo4j and I am going through the Movie dataset from the built-in examples that comes with Neo4j browser
The first query that was presented in the tutorial is:
MATCH (tom {name: "Tom Hanks"}) RETURN tom
I was expecting to get one node as a result, but on executing I get 4 nodes instead. The textual representation of the output is:
════════════════════════════════╕
│"tom" │
╞════════════════════════════════╡
│{"name":"Tom Hanks","born":1956}│
├────────────────────────────────┤
│{"name":"Tom Hanks","born":1956}│
├────────────────────────────────┤
│{"name":"Tom Hanks","born":1956}│
├────────────────────────────────┤
│{"name":"Tom Hanks","born":1956}│
└────────────────────────────────┘
Any one kind enough to provide an explanation for this? Or guide to where such explanation is provided? Thanks!
Hi Finlay,
Please provided the label(s) for the node that you wish to match.
For example, MATCH (tom:Person {name: "Tom Hanks"}) RETURN tom;
Without the label, your query will match all types of nodes that have a name property of 'Tom Hanks' and will return all the matched nodes.
Does this help?
Thanks for the tip.
I ran your suggested query:
MATCH (tom:Person {name: "Tom Hanks"}) RETURN tom;
and indeed it now returns only one node...
but then again I ran my original query:
MATCH (tom {name: "Tom Hanks"}) RETURN tom
and now, it is also returning only one results!!!
I do not know what is going on...
but thanks again for your suggestion.
The only thing I can think of here is that you may have created the movies db multiple times, so there may be multiple nodes for Tom Hanks the query is matching upon.
That said...your output here seems only partial, with a separator between an empty or deleted result, which suggests that your query was returning something more besides Tom Hanks. That suggests at least that the query you gave us isn't really the query you ran.
If you can provide the full query, that would probably give us enough info to explain what you are seeing.