Expand my Community achievements bar.

SOLVED

Search Multiple Paths for Quick Search Core Component or Other Method

Avatar

Level 3

I need to create a search page that queries multiple paths.  For example, /content/mypages and the corresponding PDFs in assets (/content/dam/mypages).  Using Quick Search, it looks like Search Root only accepts one path.  Is there a way to accomplish this using Quick Search or other method?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@AEM_Dan You can provide multiple search paths in your query. For example:-

 

type=cq:Page

1_group.1_path=/content/we-retail/it

1_group.2_path=/content/we-retail/fr

1_group.3_path=/content/we-retail/us

1_group.p.or=true

orderby=@jcr:lastModified

orderby.sort=desc

 

However in your user case, you want to search in pages as well in the dam assets and due to that type of the query would differ. I think in that case you need to execute the queries separately and combine the result to display it on search results page.

View solution in original post

8 Replies

Avatar

Correct answer by
Community Advisor

@AEM_Dan You can provide multiple search paths in your query. For example:-

 

type=cq:Page

1_group.1_path=/content/we-retail/it

1_group.2_path=/content/we-retail/fr

1_group.3_path=/content/we-retail/us

1_group.p.or=true

orderby=@jcr:lastModified

orderby.sort=desc

 

However in your user case, you want to search in pages as well in the dam assets and due to that type of the query would differ. I think in that case you need to execute the queries separately and combine the result to display it on search results page.

Avatar

Level 3

So you are talking about the Query Builder API search.  I can confirm that works.  You can just remove the type= and it will search all types, for example:

fulltext=Management
group.p.or=true
group.1_path=/content/geometrixx/en/company/management
group.2_path=/content/geometrixx/en/company/bod

But is there a way to do this with the Core Components search?

Avatar

Community Advisor

@AEM_Dan After analyzing the code for the OOB core search component, search would only work for a single root path. You would have to write your custom logic in case you want to implement search on multiple paths. 

 

https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/w... 

 

Hope this helps!!!

Avatar

Level 5

Could you please explain more on the requirement, do you want to search pages and corresponding pdfs associated with it ?

 

Avatar

Level 3

Correct.  But it really just boils down to searching multiple paths regardless of type.

/content/mypages

/content/dam/mypagespdfs

Avatar

Level 3

Thank you.  I found that post also but it's quite old so I didn't know if those methods were still valid.

Avatar

Community Advisor

Hi,

you can divide your search criteria into multiple groups, let's say group1 for the property, group2 for path and group3 for type

and apply AND group operation.

Please check below query :

group.1_group.1_property=color

group.1_group.1_property.operation= exists

group.1_group.2_property=font

group.1_group.2_property.operation= exists

group.1_group.p.or=true

group.2_group.1_path=/content/geometrixx/en

group.2_group.2_path=/content/dam/geometrixx

group.2_group.p.or=true

group.3_group.1_type=cq:Page

group.3_group.2_type=dam:Asset

group.3_group.p.or=true

group.p.and=true

 

Ref : https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/query-builder-ootb-servlet...

 

Hope this will help you .

 

Thanks