Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Sql2 query to find pages containing duplicate property value

skmAem
Level 3
Level 3

Hi AEM Gurus,

 

Is it possible to use jcr sql2 query to find pages that contain the same id value (supposed to be unique but got duplicated some how) in one of the custom page property? I have tried with this sql2 query but it fails since we can't compare a dynamic operand against a dynamic operand. Since sql2 doesn't have group by, having clauses, my choices seem to be limited. I also tried playing around with not issamenode but no luck so far.

 

select n1.[jcr:path], n2.[jcr:path] from [cq:PageContent] as n1 INNER JOIN [cq:PageContent] as n2
ON n1.[custom_id] = n2.[custom_id]
where ISDESCENDANTNODE(n1, "/content") and ISDESCENDANTNODE(n2, "/content")
and n1.[jcr:path] <> n2.[jcr:path]

 

So basically custom_id page property should have been unique across repository but with users copy/pasting pages, same custom_id value can be on multiple pages and we need to find these pages.

 

Thanks in advance,

SKM

 

1 Accepted Solution
narendragandhi
Correct answer by
Level 3
Level 3

Hi, It may not exactly be the solution you are looking for but you could run a query to get all page path and custom_id and then run export the result into an excel and find out the duplicates. You can use http://localhost:4502/editor.html/var/acs-commons/reports/custom.html to run queries and download results.

 

Screen Shot 2020-08-07 at 3.48.24 PM.png

View solution in original post

4 Replies
skmAem
Level 3
Level 3

Asking it again to see if anyone has pointers...

narendragandhi
Level 3
Level 3

Hi, It may not exactly be the solution you are looking for but you could run a query to get all page path and custom_id and then run export the result into an excel and find out the duplicates. You can use http://localhost:4502/editor.html/var/acs-commons/reports/custom.html to run queries and download results.

 

Screen Shot 2020-08-07 at 3.48.24 PM.png

skmAem
Level 3
Level 3
Thanks @narendragandhi, Excellent suggestion! I can probably use json to csv converter to convert results into csv/xsl and then sort by property to see if any duplicates.
narendragandhi
Correct answer by
Level 3
Level 3

Hi, It may not exactly be the solution you are looking for but you could run a query to get all page path and custom_id and then run export the result into an excel and find out the duplicates. You can use http://localhost:4502/editor.html/var/acs-commons/reports/custom.html to run queries and download results.

 

Screen Shot 2020-08-07 at 3.48.24 PM.png

View solution in original post