Re: Cypher : Getting all nodes which have a property

2,589 views
Skip to first unread message

dn

unread,
Jul 28, 2012, 4:15:56 AM7/28/12
to ne...@googlegroups.com
Ahh, think I worked it out.

Adding all nodes that I create to an index such as "MYINDEX" with property "myProp" as some value, and then in the Cypher query I search through the index
START n=node:MYINDEX(myProp="myValue") RETURN n

Peter Neubauer

unread,
Jul 28, 2012, 4:55:09 AM7/28/12
to ne...@googlegroups.com

That's it.

/peter

Send from mobile.

Jim Webber

unread,
Jul 28, 2012, 4:35:54 PM7/28/12
to ne...@googlegroups.com
Hi Andy,

I think what you're outlining is a little bit tricky in Cypher right now. It's easy to solve by indexing those nodes that have a particular key, and then subsequently filtering that in Cypher. But setting that up solely in Cypher today isn't possible - you'll need to dip into another API (REST, Java) to do the indexing bit.

FWIW the team will be sorting out auto indexes and making them on a par with regular indexes soon enough, and once that's done it opens the way for Cypher to deliver the index operations you're looking for. But that won't be in the 1.8 release.

Jim

Shelley Tong

unread,
Jul 24, 2013, 12:23:10 PM7/24/13
to ne...@googlegroups.com
If I didn't create an index, how do I execute the same query?

If that's not possible, how do I create an index to my already existing nodes and relationships?

Shelley

Rodger

unread,
Jul 24, 2013, 1:17:22 PM7/24/13
to ne...@googlegroups.com, andy_je...@yahoo.com
Shelly, without auto_indexes, you can use the has () clause


START n=node(*) 
WHERE has (n.myProp)
and n.myProp="someValue"
RETURN n


In my experience, has () must be on the first line in the WHERE clause,
otherwise you will get the error that the node(0) does not have the property.

HTH


Rodger

unread,
Jul 24, 2013, 1:25:43 PM7/24/13
to ne...@googlegroups.com, andy_je...@yahoo.com
In Version 2, you can also filter on the Label, using this syntax:


start n=node(*)
MATCH (n:OBJECT)
where  n.object_type? = 'TABLE'
RETURN n

Note the question mark.



Wes Freeman

unread,
Jul 24, 2013, 1:43:23 PM7/24/13
to ne...@googlegroups.com
You should omit the start clause for this one.

Michael Hunger

unread,
Jul 25, 2013, 5:59:32 AM7/25/13
to ne...@googlegroups.com
Create index on :Object(object_type);

MATCH (n:OBJECT)
where  n.object_type = 'TABLE'
RETURN n

Will use an index lookup

Sent from mobile device
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages