0
繼續我的上一個問題Neo4j Cypher query null or IN我已將isPublic
屬性添加到Tenant
節點。Neo4j Cypher布爾條件和IN
現在我需要延長親切的frant.hartm有額外的檢查創建的查詢parentD
和childD
租戶isPublic
條件。
我已經延長我的聲明以下幾點:
t.isPublic OR t in tenants WHERE (parentD)-[:BELONGS_TO]-(t)
,但它無法用以下異常:
org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: Neo.ClientError.Statement.SyntaxError; Description: Invalid input 'W': expected whitespace, comment, '{', node labels, MapLiteral, a parameter, a relationship pattern, '(', '.', '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or ')' (line 1, column 254 (offset: 253))
"MATCH (t:Tenant) WHERE ID(t) in {tenantIds} WITH COLLECT(t) as tenants MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} AND (not(parentD)-[:BELONGS_TO]-(:Tenant) OR any(t.isPublic OR t in tenants WHERE (parentD)-[:BELONGS_TO]-(t))) AND (not (childD)-[:BELONGS_TO]-(:Tenant) OR any(t.isPublic OR t in tenants WHERE (childD)-[:BELONGS_TO]-(t))) RETURN ru, u, childD ORDER BY childD.createDate ASC SKIP 0 LIMIT 100"
^
at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.executeRequest(EmbeddedRequest.java:175)
at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.execute(EmbeddedRequest.java:66)
完整的查詢現在的樣子:
MATCH (t:Tenant) WHERE ID(t) in {tenantIds}
WITH COLLECT(t) as tenants
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User)
WHERE
id(parentD) = {decisionId}
AND
(not(parentD)-[:BELONGS_TO]-(:Tenant) OR any(t.isPublic OR t in tenants WHERE (parentD)-[:BELONGS_TO]-(t)))
AND
(not (childD)-[:BELONGS_TO]-(:Tenant) OR any(t.isPublic OR t in tenants WHERE (childD)-[:BELONGS_TO]-(t)))
RETURN ru, u, childD
ORDER BY childD.createDate ASC
SKIP 0 LIMIT 100
如何修復此查詢以支持t.isPublic
?
感謝您的回答。在這種情況下,查詢沒有例外,但在這個地方看起來像「t.isPublic」沒有意義,因爲最後我們檢查'tennats'中的't' ..但是'tenants'可能不包含'Tenant',其中't .isPublic == true' ..我應該添加僅用於't.isPublic'條件的第三個'OR'語句嗎? – alexanoid
以前我有兩個條件 - 對於不屬於任何租戶的決策,對於屬於租戶的決定{tenantIds} ..現在我必須爲屬於租戶的決策添加第三個條件,並且isPublic == true。現在我不知道如何爲額外的OR語句編寫這個布爾語句 – alexanoid