Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-15-2020 02:24 AM
HI
I can't get the following commands to work together. individually they do work
1st command
MATCH (a) WITH LABELS(a) AS temp UNWIND temp AS LABELLIST return DISTINCT LABELLIST;
gives me
LABELLIST
"node"
"status"
"process"
"org"
"account"
"mail"
"person"
"topic"
"course"
"exam"
"exam_certificate"
2nd command
MATCH (n:org)-[:managed_by_process]->(m) return DISTINCT m.guid;
is working and gives me "a83265b2-3fbc-48bd-855e-504436ffc736"
togehether gives me nothing - the label shall be from the list ....
MATCH (a) WITH DISTINCT LABELS(a) AS temp UNWIND temp AS LABELLIST
MATCH (n:LABELLIST)-[:managed_by_process]->(m) return m;
Thanks for help rob
also NOT working
MATCH (a) WITH DISTINCT LABELS(a) AS temp UNWIND temp AS LABELLIST
WITH LABELLIST
MATCH (n:LABELLIST)-[:managed_by_process]->(m) return m;
Solved! Go to Solution.
12-15-2020 10:25 AM
Try this:
MATCH (n)-[:managed_by_process]->(m) return distinct labels(n) as lbl, m.guid
12-15-2020 09:28 AM
im interested to know what the end goal is. for example
MATCH (a) WITH DISTINCT LABELS(a) AS temp UNWIND temp AS LABELLIST
WITH LABELLIST
MATCH (n:LABELLIST)-[:managed_by_process]->(m) return m;
appears to be
line1: traverse all nodes and collect all distinct labels for all nodes and then unwind from this set each label
line3: for each label find all nodes for this label see if it has a :managed_by_process relationship pointing to any other node and then return this any other node.
Why not simply
MATCH (n)-[:managed_by_process]->(m) return m;
which says, traverse all nodes see it it has a relationship named :managed_by_process pointing to some other node and then return that other node?
12-15-2020 10:03 AM
hi Dana
Thanks your answere helped me a lot - sometimes you can't see the forest for the trees
my soltion is now
MATCH (n)-[:managed_by_process]->(m) return labels(n), m.guid
im interested to know what the end goal is.
the result tells me that all nodes with the label e.g. "mail" have the managing process with the GUID "0d821309-b677-49d6-b7b4-7083e8fd5a86"
at the moment the result is not distinct (over all cells in a row)
I get
["mail"] "0d821309-b677-49d6-b7b4-7083e8fd5a86"
["mail"] "0d821309-b677-49d6-b7b4-7083e8fd5a86"
["exam_certificate"]"ff698ee5-76e4-4903-8f97-cb1d4949a8b1"
["exam_certificate"]"ff698ee5-76e4-4903-8f97-cb1d4949a8b1"
["exam_certificate"]"ff698ee5-76e4-4903-8f97-cb1d4949a8b1"
["exam"] "15949010-a42a-44b4-9d22-aa17f68afb1b"
["exam"] "15949010-a42a-44b4-9d22-aa17f68afb1b
perefect would be
["mail"] "0d821309-b677-49d6-b7b4-7083e8fd5a86"
["exam_certificate"]"ff698ee5-76e4-4903-8f97-cb1d4949a8b1"
["exam"] "15949010-a42a-44b4-9d22-aa17f68afb1b"
I tried
MATCH (n)-[:managed_by_process]->(m) return distinct (labels(n), m.guid)
which is not working , so my workarround is
MATCH (n)-[:managed_by_process]->(m) return distinct (labels(n)+m.guid)
12-15-2020 10:19 AM
just a note that your queries though valid are performing a allNodesScan. so if you have 100 million nodes, then each time you run the query then we will traverse all 100 million nodes.
Now if you changed for example
MATCH (n)-[:managed_by_process]->(m) return distinct (labels(n)+m.guid)
to
MATCH (n:mail)-[:managed_by_process]->(m) return distinct (labels(n)+m.guid)
and of the 100 million total nodes in the graph, if only 8 million had a label of mail
then we would only travese 8 million nodes
12-15-2020 10:25 AM
Try this:
MATCH (n)-[:managed_by_process]->(m) return distinct labels(n) as lbl, m.guid
12-15-2020 10:55 AM
my final solution is this (incuding all keys per label)
MATCH (n)-[:managed_by_process]->(m) return distinct labels(n) as lbl, COLLECT(distinct (apoc.coll.sort(keys(n)))) as kys, m.guid
with the help of this answer to my "old" question Keys(n) sorting problems with DISTINCT
THANKS a lot - greate Community here !
All the sessions of the conference are now available online