cypher distinct 使用 with 参数返回重复项
cypher distinct is returning duplicate using with parameter
MATCH (c:someNode) WHERE LOWER(c.erpId) contains (LOWER("1"))
OR LOWER(c.constructionYear) contains (LOWER("1"))
OR LOWER(c.label) contains (LOWER("1"))
OR LOWER(c.name) contains (LOWER("1"))
OR LOWER(c.description) contains (LOWER("1"))with collect(distinct c) as rows, count(c) as total
MATCH (c:someNode)-[adtype:OFFICIAL_someNode_ADDRESS]->(ad:anotherObject)
WHERE toString(ad.streetAddress) contains "1"
OR toString(ad.postalCity) contains "1"
with distinct rows+collect( c) as rows, count(c) +total as total
UNWIND rows AS part
RETURN part order by part.name SKIP 20 Limit 20
当我运行下面的密码查询它returns重复的结果。此外,跳过似乎不起作用。我在做什么 wearng
当您使用 WITH DISTINCT a, b, c
(或 RETURN DISTINCT a, b, c
)时,这仅意味着您希望每个结果记录 ({a: ..., b: ..., c: ...}
) 是不同的——它不会以任何方式影响a
、b
或 c
.
的任何列表的内容
下面是一个可能适合您的简化查询。它根本不使用 LOWER()
和 TOSTRING()
函数,因为它们看起来是多余的。它还仅使用单个 MATCH/WHERE
对来查找所有感兴趣的节点。 pattern comprehension 语法用作 WHERE
子句的一部分以获取 non-empty 列表 true
值当且仅当存在任何 anotherObject
节点(s ) 出于兴趣。请注意,不需要 DISTINCT
。
MATCH (c:someNode)
WHERE
ANY(
x IN [c.erpId, c.constructionYear, c.label, c.name, c.description]
WHERE x CONTAINS "1") OR
[(c)-[:OFFICIAL_someNode_ADDRESS]->(ad:anotherObject)
WHERE ad.streetAddress CONTAINS "1" OR ad.postalCity CONTAINS "1"
| true][0]
RETURN c AS part
ORDER BY part.name SKIP 20 LIMIT 20;
MATCH (c:someNode) WHERE LOWER(c.erpId) contains (LOWER("1"))
OR LOWER(c.constructionYear) contains (LOWER("1"))
OR LOWER(c.label) contains (LOWER("1"))
OR LOWER(c.name) contains (LOWER("1"))
OR LOWER(c.description) contains (LOWER("1"))with collect(distinct c) as rows, count(c) as total
MATCH (c:someNode)-[adtype:OFFICIAL_someNode_ADDRESS]->(ad:anotherObject)
WHERE toString(ad.streetAddress) contains "1"
OR toString(ad.postalCity) contains "1"
with distinct rows+collect( c) as rows, count(c) +total as total
UNWIND rows AS part
RETURN part order by part.name SKIP 20 Limit 20
当我运行下面的密码查询它returns重复的结果。此外,跳过似乎不起作用。我在做什么 wearng
当您使用 WITH DISTINCT a, b, c
(或 RETURN DISTINCT a, b, c
)时,这仅意味着您希望每个结果记录 ({a: ..., b: ..., c: ...}
) 是不同的——它不会以任何方式影响a
、b
或 c
.
下面是一个可能适合您的简化查询。它根本不使用 LOWER()
和 TOSTRING()
函数,因为它们看起来是多余的。它还仅使用单个 MATCH/WHERE
对来查找所有感兴趣的节点。 pattern comprehension 语法用作 WHERE
子句的一部分以获取 non-empty 列表 true
值当且仅当存在任何 anotherObject
节点(s ) 出于兴趣。请注意,不需要 DISTINCT
。
MATCH (c:someNode)
WHERE
ANY(
x IN [c.erpId, c.constructionYear, c.label, c.name, c.description]
WHERE x CONTAINS "1") OR
[(c)-[:OFFICIAL_someNode_ADDRESS]->(ad:anotherObject)
WHERE ad.streetAddress CONTAINS "1" OR ad.postalCity CONTAINS "1"
| true][0]
RETURN c AS part
ORDER BY part.name SKIP 20 LIMIT 20;