how to find the title which is repeated among two different content path using querybuilder

Avatar

Avatar
Ignite 1
Level 2
nareshkumarpart
Level 2

Likes

3 likes

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 3
Boost 1
View profile

Avatar
Ignite 1
Level 2
nareshkumarpart
Level 2

Likes

3 likes

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 3
Boost 1
View profile
nareshkumarpart
Level 2

24-06-2020

Hi,

how to find the title which is repeated among two different content path using querybuilder in aem 6.5.

i need this result as com.day.cq.search.result.SearchResult result. i am using this result object for pagination, total cound , exeution time in search results.

i have tried with below approach

- i have using the below constrainsts and getting the results then assign to one list and finding the repeated title then using result list. but while doing pagination and total count its giving worng data.

predicate:

1_group.1_path=/content/med/en/hm/pa/comm
1_group.2_path=/content/med/en/hw/pa/comm
1_group.p.or=true
p.limit=10
p.excerpt=false
orderby.sort=desc
p.offset=0,
2_property=jcr:content/policy-details/number

2_property.value=D-666
orderby=@jcr:content/policy-details/version
type=cq:Page

but i want to achieve this in query itself. 

could you please give me right direction.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

29-06-2020

Reply from @nareshkumarpart 

Thanks, Vaibhavi, Actually I have written the utility to remove the duplicates and setting the node property. So after that, I have matching the predicates in our application to fetch the records in a search. it gives somehow better performance, and without affecting the pagination logic.

 

@nareshkumarpart Can you please share some more details about this utility for posterity?

Answers (3)

Answers (3)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

25-06-2020

Use SQL2 queries to perform complex comparison.

Avatar

Avatar
Ignite 1
Level 2
nareshkumarpart
Level 2

Likes

3 likes

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 3
Boost 1
View profile

Avatar
Ignite 1
Level 2
nareshkumarpart
Level 2

Likes

3 likes

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 3
Boost 1
View profile
nareshkumarpart
Level 2

25-06-2020

Thanks vaibhavi for your response. 

- Actually the issue , Same title presents in two different content path. i want to make it one and show it in results.

Is there any way to find the repeated title in two different path . Any join quires can achieve this using query builder.

If i get the answer for this i can resolve this issue..

 

Thanks in advance for your responses.

Vaibhavi

Hi Naresh,

I got your problem. Query will return both the result as path is different and data will not be treated as duplicate. But you have a way to filter. 

After you get result you can filter out the duplicates by comparing duplicate titles. 

 

 

nareshkumarpart

Thanks vaibhavi for the response. I did the same way,but if i am doing like that i am facing some issue with manipulate in the pagination section. Because result object provided some default methods like getResultpage,getNextPage,getPreviouspage for the pagination section. So i am exploring to do this with using querybuilder with result object. if i am remove the duplicates in query itself with some inner query or join query . Is it possible to make it in query itself. 

 

Thanks,

Naresh

Vaibhavi

Hi Naresh,

No, Achieving the same using querybuilder is not possible. As I mentioned below two paths with same title will not be treated as duplicate. 

 

You can try with SQL queries but you have mentioned that you want to achieve using same query. 

 

You can go with of one of the solution below:

1.Customize the pagination part, you can apply the pagination on filtred result (after you removing the duplication). You can use thridparty libraries like smarttable (many thridparty libs are available, you can choose) to achieve pagination easily. 

2.Switch to SQL

nareshkumarpart
Thanks vaibhavi, Actually i have writing the utility to remove the duplicates and setting the node property . So after that i have matching the predicates in our application to fetch the records in search. it give some how better performance , and without affecting the pagination logic.
Vaibhavi
Good👍. Custom solution resolved the issue without making an impact on performance

Avatar

Avatar
Affirm 50
MVP
Vaibhavi
MVP

Likes

216 likes

Total Posts

181 posts

Correct reply

61 solutions
Top badges earned
Affirm 50
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Affirm 50
MVP
Vaibhavi
MVP

Likes

216 likes

Total Posts

181 posts

Correct reply

61 solutions
Top badges earned
Affirm 50
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
Vaibhavi
MVP

24-06-2020

Hi @nareshkumarpart 

 

In below query offset and plimit value is statically set. So during pagination you are not receiving the proper count. 

 

Solution:

Please update the offset and plimit value dynamically. Example:From above query,in first iteration you have received the results from 0(offset is set to 0)to 10(plimit is set for 10 records). In second iteration you should fetch next 10 result, so your offset should be updated to 10 and plimit as 20.

This should fix your issue. 

Below summarizing for better understanding:

  • p.offset defines start of index means from which index you want to fetch records from query result.
  • p.limit defines how many records you want to fetch.
  • Each query result will display results from p.offset to p.offset + p.limit.

Regards, 

Vaibhavi