Neo4j,其中 predicate 针对多个属性

mftmpeh8  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(145)

在Neo4j中,对于where predicate ,我们可以对多个属性进行约束吗?例如,假设我们有一个对列表:L = [(23,“San Diego”),(25,“Palo Alto”),(21,“Seattle”),....],则Cypher是否支持类似于以下内容的内容:

Match (a) where (a.age, a.city) in L return a

年龄和城市组合需要在L列表中

6tdlim6h

6tdlim6h1#

Neo4j不接受元组,但接受键、值对(或字典)的Map。
但是,此查询将接近您所描述的内容。

WITH [{age:23, city:'San Diego'}, {age:25, city:'Palo Alto'}, {age:21, city:'Seattle'}] as L
MATCH (p:Person) WHERE {age: p.age, city: p.city} in L
RETURN p 

Sample result:
╒═══════════════════════════════════════════╕
│"p"                                        │
╞═══════════════════════════════════════════╡
│{"name":"Andy","city":"San Diego","age":23}│
└───────────────────────────────────────────┘

见下图:

https://neo4j.com/docs/cypher-manual/current/syntax/values/#composite-types

相关问题