简体   繁体   English

密码neo4j查询中的NOT()

[英]WHERE NOT() in cypher neo4j query

I am having trouble with a simple cypher query. 我在使用简单的密码查询时遇到了麻烦。 The query is: 查询是:

MATCH (u:user { google_id : 'example_user' })--(rm:room)--(a:area),
    (c:category { name : 'culture:Yoruba' })--(o:object) 
WHERE NOT (a-[:CONTAINS]->o) 
RETURN DISTINCT o.id

The "WHERE NOT.." is being ignored and I am getting back the nodes with incoming :CONTAINS relationships from the area nodes. “ WHERE NOT ..”被忽略,我从区域节点获取具有传入:CONTAINS关系的节点。 If I take out the "NOT" function, then I correctly only get back the nodes that have this a-->o relationship. 如果我删除了“ NOT”功能,那么我只会正确地获得具有这种a-> o关系的节点。

I think I have a weak understanding of NOT() 我认为我对NOT()的理解较弱

Trad, 传统

The query is returning just what you asked it to. 查询将返回您要求的内容。 In your example at the link, there are three areas. 在链接的示例中,有三个区域。 None of the objects are contained by the first two areas, so all three nodes are returned. 前两个区域都不包含任何对象,因此将返回所有三个节点。 If you change the RETURN line to 如果您将RETURN行更改为

RETURN a.area_number, o.id

you will see this. 你会看到这个。

I don't know about your larger problem context, but if you want to know about objects that aren't in any area, then the query 我不了解您的较大问题上下文,但是如果您想了解不在任何区域的对象,则可以查询

MATCH (o:object)
WHERE NOT (o)<-[:CONTAINS]-()
RETURN o.id

will accomplish the task. 将完成任务。

Grace and peace, 恩典与和平

Jim 吉姆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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