Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-05-2020 06:41 AM
We have run into a situation where we need to create a master node for certain templates.
We can get the distinct templates easy enough:
match (b {KDM:'TemplateParameter'}) return distinct(b.Label)
But I am not clear on how I would create 1 node from each distinct(b.Label). Tried this one
match (b {KDM:'TemplateParameter'}) distinct(b.Label) as Templates
with Templates merge (a:LibNode {Label:Templates.Label})
We need some of the properties from the b nodes in addition to the label but that is easy to do later
Thanks
Solved! Go to Solution.
11-05-2020 11:31 AM
Try this:
with collect (distinct b.Label) as Templates
FOREACH (plates in Templates |
merge (a:LibNode {Label:plates})
)
11-05-2020 09:03 AM
Well we already had the distinct. So the first query in my question returns a set of unique templates. The query you gave was really no improvement on that UNLESS
propertyvalues can somehow be used directly in the create ? Can't use APOC here.
11-05-2020 11:31 AM
Try this:
with collect (distinct b.Label) as Templates
FOREACH (plates in Templates |
merge (a:LibNode {Label:plates})
)
11-05-2020 12:57 PM
That was nicely done. Loved the alliteration on "plates". Thank you
11-05-2020 01:44 PM
Thanks for your appreciation!
All the sessions of the conference are now available online