Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

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

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Administrator

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?



Kautuk Sahni

View solution in original post

9 Replies

Avatar

Community Advisor

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

Avatar

Level 2

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.

Avatar

Community Advisor

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. 

 

 

Avatar

Level 2

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

Avatar

Community Advisor

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

Avatar

Level 2
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.

Avatar

Community Advisor
Good. Custom solution resolved the issue without making an impact on performance

Avatar

Community Advisor

Use SQL2 queries to perform complex comparison.



Arun Patidar

Avatar

Correct answer by
Administrator

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?



Kautuk Sahni