0
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

当我运行以下密码查询时,它会返回重复的结果。而且它的跳过似乎不起作用。我在做什么

4

1 回答 1

1

当您使用WITH DISTINCT a, b, c(or RETURN DISTINCT a, b, c) 时,这仅表示您希望每个结果记录 ( {a: ..., b: ..., c: ...}) 是不同的——它不会以任何方式影响可能属于 、 或 的任何列表ab内容c

下面是一个可能对您有用的简化查询。它根本不使用LOWER()andTOSTRING()函数,因为它们看起来是多余的。它也只使用一MATCH/WHERE对来查找所有感兴趣的节点。如果存在任何感兴趣的节点,则模式理解语法用作WHERE子句的一部分以获取非空值列表。请注意,这不是必需的。trueanotherObjectDISTINCT

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;
于 2018-03-22T19:50:50.633 回答