Neo4J - 根据一些 属性 不存在的过滤结果
Neo4J - Get filtered results based on some property that does not exist
有 product
可以有多个 ProductImage
。我想根据图像 属性 isUseful
获取产品(给定其 ID)及其相关图像。只应获取那些没有 isUseful
属性 可用的图像。我有这个查询:
MATCH (product:Product)
WHERE product.id = $productId
RETURN product{
.*,
images: [(product)<-[:BELONGSTO]-(image:ProductImage {isUseful: null}) | image{.*}]
}
此查询没有return任何结果。但是数据库里有记录。请注意,我只能更改 return
块中的内容。其他都不能改变。
你不能对 null 使用相等,你需要使用 IS NULL
。请在此处查看文档:
https://neo4j.com/docs/cypher-manual/current/syntax/working-with-null/
因此,您需要在模式理解中添加一个 WHERE 子句以获得您想要的结果:
[(product)<-[:BELONGSTO]-(image:ProductImage) WHERE image.isUseful IS NULL | image{.*}]
有 product
可以有多个 ProductImage
。我想根据图像 属性 isUseful
获取产品(给定其 ID)及其相关图像。只应获取那些没有 isUseful
属性 可用的图像。我有这个查询:
MATCH (product:Product)
WHERE product.id = $productId
RETURN product{
.*,
images: [(product)<-[:BELONGSTO]-(image:ProductImage {isUseful: null}) | image{.*}]
}
此查询没有return任何结果。但是数据库里有记录。请注意,我只能更改 return
块中的内容。其他都不能改变。
你不能对 null 使用相等,你需要使用 IS NULL
。请在此处查看文档:
https://neo4j.com/docs/cypher-manual/current/syntax/working-with-null/
因此,您需要在模式理解中添加一个 WHERE 子句以获得您想要的结果:
[(product)<-[:BELONGSTO]-(image:ProductImage) WHERE image.isUseful IS NULL | image{.*}]