Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-15-2020 08:13 PM
I have the following "node hierarchy": (:MediaHost) has multiple (:Bucket)s and each bucket can have multiple (:MediaFile)s and are related like so:
(h:MediaHost)-[:HAS_BUCKET]->(b:Bucket)-[:LINKS_TO_FILE]->(f:MediaFile)
So, for getting 2 files from each bucket for a given host, and return a table, I do the following
MATCH (h: MediaHost {hostname: 'myhost.com'}) -[:HAS_BUCKET]-> (b: Bucket) -[:LINKS_TO_FILE]-> (f: MediaFile) WITH h, b, COLLECT(f)[0..2] AS files UNWIND files AS file RETURN b.name AS bucket_name, file.name ORDER BY b.name, file.name
This works well.
The files also "belong" to a (:MediaDir) node like so:
(d:MediaDir)-[:HAS_FILE]->(f:MediaFile)
I am trying to get the dir of each file like so:
MATCH (h: MediaHost {hostname: 'myhost.com'}) -[:HAS_BUCKET]-> (b: Bucket) -[:LINKS_TO_FILE]-> (f: MediaFile) WITH h, b, COLLECT(f)[0..2] AS files UNWIND files AS file MATCH (d:MediaDir)-[:HAS_FILE]->(file) RETURN b.name AS bucket_name, file.name, d.name ORDER BY b.name, file.name
Once I introduce the last MATCH section in the query to get the file's directory, I get duplicate MediaFiles.
However, without the last MATCH section, I don't get the duplicates.
Can anyone suggest what's wrong in my query?
Solved! Go to Solution.
06-15-2020 08:23 PM
Never mind.
It was a data problem: two (:MediaDir)s were linking to the same (:MediaFile).
06-15-2020 08:18 PM
I am attaching the same queries above as image for better readability and line# to refer to in the discussion:
06-15-2020 08:23 PM
Never mind.
It was a data problem: two (:MediaDir)s were linking to the same (:MediaFile).
All the sessions of the conference are now available online