Return 个节点包含 属性 个与列表中的子字符串匹配的值
Return nodes containing property values matching substrings in a list
我有一个数据库,其中的节点有 属性 "name",值在列表 "first_1"、"first_2"、"second_1"、"second_2" 中, "third_1", "third_2" (每个节点只有一个值)我想 return 具有 属性 "name" 的节点的值包含子字符串"first" 或 "second"。所以查询应该 return 所有节点 "name" 属性 包含 "first_1" 或 "first_2" 或 "second_1" 等等但不包含"third_*"。理想的 Cypher 查询应该是什么?
您可以使用 any()
函数和 starts with
:
试试这个 Cypher
with ['first', 'second'] as list
match (n)
where any (item in list where n.name starts with item)
return n
我有一个数据库,其中的节点有 属性 "name",值在列表 "first_1"、"first_2"、"second_1"、"second_2" 中, "third_1", "third_2" (每个节点只有一个值)我想 return 具有 属性 "name" 的节点的值包含子字符串"first" 或 "second"。所以查询应该 return 所有节点 "name" 属性 包含 "first_1" 或 "first_2" 或 "second_1" 等等但不包含"third_*"。理想的 Cypher 查询应该是什么?
您可以使用 any()
函数和 starts with
:
with ['first', 'second'] as list
match (n)
where any (item in list where n.name starts with item)
return n