June
June

Reputation: 27

What is the appropriate cypher query?

I am trying to run the web ui on

7474/webadmin/#

Suppose I want to find a node that has a property "title" with a value of "Home". How do I find that node using a cypher query? (There should be only one node.)

Also, suppose I want to retrieve a relationship? Let's say I have the following: A -entitledTo-> B -entitledTo-> C

I have already tried the following: start n=node(*) where n.title='Home' return n;

start c=node(node_c_id) match a-[:entitledTo]->b-[:entitledTo]->c return a,b,c;

However, I get this error message: The property 'title' does not exist on Node[0]

How do I resolve this issue?

Lastly, this is version 2.0.0-M03

Upvotes: 0

Views: 68

Answers (3)

user2622477
user2622477

Reputation: 31

You can use:

start n=node(*) where n.title! ='Home' return n;

See the section on missing properties in where clauses

Upvotes: 1

Eddie Dickey
Eddie Dickey

Reputation: 72

To retrieve the Relationships, perhaps the Cypher PATH command could be usefull.

Upvotes: 0

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

use:

start n=node(*) where has(n.title) and n.title='Home' return n

In general you should consider using indexes for this kind of operation, Neo4j's reference manual has lots of information about this.

Upvotes: 1

Related Questions