刚开始使用neo4j并认为我会使用真人模型自学。陷入以下困境
(d:Destination)-[:Hosts]->(a:Accommodation)
:Accommodation is sub-typed with other labels as :Homestay / :Hotel / :Guesthouse etc.
对于给定的d.name
,想要检索按子类别分组的所有a.names
非常感谢帮助
答案 0 :(得分:3)
这应该有效:
$ IMAGE_ID=$(docker images -q | head -1)
如果要查询子类型,可能更容易将它们放在节点属性中。
答案 1 :(得分:2)
要在Martin Preusse的解决方案上进行分层,您可以在临时步骤中过滤掉 Accomodation 标签并返回第0个元素。这假定当然至少有两个标签开始(即确实存在子分类)。
match (d:Destination)-[:HOSTS]->(a:Accomodation)
with d
, a
, filter(type in labels(a) where type <> 'Accomodation')[0] as type
return d.name, type, collect(a.name)