Filtering Cypher results based on parameter being true

6 views
Skip to first unread message

Chris Bolton

unread,
Oct 26, 2012, 11:15:59 AM10/26/12
to ne...@googlegroups.com
Hi all,

I have a query:

START n=node(4) MATCH(n)-[:friends]->(x) RETURN x

My problem is that those friends being returned have a property attached to them called interests which is an array. What I need to do is take my single interest and see if it is located in the array, if so return those users.

My best guess right now is:

q = incoming interest parameter
START n=node(4) MATCH(n)-[:friends]->(x) WHERE(x.interests.to_s =~ /(?i-mx:.*#{q}.*)/ RETURN x

Any help would be appreciated.

Thanks.
Chris Bolton

Andres Taylor

unread,
Oct 26, 2012, 11:36:54 AM10/26/12
to ne...@googlegroups.com

WHERE {q}  in x.interests

Should do it.

--
 
 

Michael Hunger

unread,
Oct 26, 2012, 11:38:09 AM10/26/12
to ne...@googlegroups.com
Is it stored as an array in the graph?

use in 

where {q} in x.interests
or if you have a more complex condition
where SINGLE( i in x.interests : i = {q} )

MIchael

--
 
 

Chris Bolton

unread,
Oct 26, 2012, 11:46:33 AM10/26/12
to ne...@googlegroups.com
Thanks Andres and Michael. I appreciate your guys help.

Chris Bolton
@Iknewthisguy

--- On Fri, 10/26/12, Andres Taylor <andres...@neotechnology.com> wrote:
--
 
 
Reply all
Reply to author
Forward
0 new messages