I would like to find the duplicates of the (:Book_Page)-nodes, BUT of course in this specific (:Book_Issue) only (because of course all books (and all issues of the books) have a page "1").
But I would like to check all (:Book)-nodes in one query.
Sorry, I don't understand where the duplication is.
Does a single Book_Issue have multiple HAS_BOOK_PAGES relationships to the same Book_Page node, so you want to find those Book_Page nodes that are related to the same Book_Issue? This scenario doesn't make sense to me.
The alternative is that a single book has multiple different issues, where some issues related to the same page. If this is the cause, I assume you want to know which pages have multiple issues.
The following should give you the results for the first scenario:
match (book:Book)-[:HAS_BOOK_ISSUE]->(issue:Book_Issue)-[:HAS_BOOK_PAGES]->(page:Book_Page)
with book, issue, page, count(page) as pageCount
where pageCount > 1
return *
match (book:Book)-[:HAS_BOOK_ISSUE]->(issue:Book_Issue)-[:HAS_BOOK_PAGES]->(page:Book_Page)
with book, page, count(page) as pageCount
where pageCount > 1
return page
I try to find out (:Book_Pages) which were mistakenly implemented in the DB, so the goal is to find these duplicates and eliminate them.
Of course each (:Book_Issue) should have only one (:Book_Page) with the property {page_no} = 1, but perhaps we (somehow) made a mistake and created a duplicate. Here is a figure with such a mistake:
Finding all (:Book_Page)-nodes and count them and display as a result all those which have a count > 1 (as you normally find duplicates) does not work, because of course all the (:Book_Issue)-nodes have such a (:Book_Page) - as you can see in the figure.
So I would like to obtain only those duplicates in a specific path (or subgraph).
So it's neither of your examples:
I'm not looking for multiple relationships
I'ts not that more than one (:Book_Issue) is related to the same (:Book_Page)
match(b:Book)-[:HAS_BOOK_ISSUE]->(i:Book_Issue)-[:HAS_BOOK_PAGE]->(p:Book_Page)
with b, i, p.page as page, collect(p) as pages
where size(pages) > 1
return b.title as bookTitle, i.name as issueDescription, page
match(b:Book)-[:HAS_BOOK_ISSUE]->(i:Book_Issue)-[:HAS_BOOK_PAGE]->(p:Book_Page)
with b, i, p.page as page, count(p) as pages
where pages > 1
return b.title as bookTitle, i.name as issueDescription, page