简体   繁体   中英

neo4j subtract elements of a path

I'm trying use this query in Cypher(Neo4):

MATCH p=(n:BP)-[:Selected]-(g:MOL)-[:Selected]-(e:BP) WHERE n.NameExp='Bos_RM' AND e.NameExp='Jac_RM' AND NONE(x IN nodes(p) WHERE x.NameExp='Jac_AGM' OR x.NameExp='Bos_SM')  RETURN n,e,g limit 100

That is, I would like exclude some nodes in path(p) that have properties 'Jac_AGM' and 'Jac_SM'. I'm using Neo4j version 2.1.3.

Thanks! Best wishes, R.

According to your query, you have already mentioned the NameExp attrib values for n and e Nodes. So its evident the nodes with the given names that you wish to be not included are among the set of g:MOL labeled nodes which you can be simply eliminated like below...

MATCH p=(n:BP)-[:Selected]-(g:MOL)-[:Selected]-(e:BP) 
WHERE n.NameExp='Bos_RM' AND e.NameExp='Jac_RM' 
AND NOT g.NameExp IN ['Jac_AGM','Jac_SM']
RETURN n,e,g limit 100

there is also an explicit option to filter nodes in the collection p :

MATCH p=(n:BP)-[:Selected]-(g:MOL)-[:Selected]-(e:BP)
WITH FILTER(x IN nodes(p): x.NameExp NOT IN ['Jac_AGM','Bos_SM']) AS pp, n, e
WHERE n.NameExp='Bos_RM' AND e.NameExp='Jac_RM'
RETURN n,e,g limit 100

source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM