Search Multiple Paths for Quick Search Core Component or Other Method | Community
Skip to main content
AEM_Dan
Level 3
November 17, 2022
Solved

Search Multiple Paths for Quick Search Core Component or Other Method

  • November 17, 2022
  • 4 replies
  • 2293 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Avinash_Gupta_

@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.

4 replies

Avinash_Gupta_
Community Advisor and Adobe Champion
Avinash_Gupta_Community Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
November 17, 2022

@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.

AEM_Dan
AEM_DanAuthor
Level 3
November 17, 2022

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?

Avinash_Gupta_
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
November 18, 2022

@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/wcm/core/components/internal/models/v1/SearchImpl.java 

 

Hope this helps!!!

Level 4
November 17, 2022

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

 

AEM_Dan
AEM_DanAuthor
Level 3
November 18, 2022

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

/content/mypages

/content/dam/mypagespdfs

SantoshSai
Community Advisor
Community Advisor
November 17, 2022
AEM_Dan
AEM_DanAuthor
Level 3
November 18, 2022

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

Community Advisor
November 18, 2022

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-multiple-paths-and-properties/td-p/315879

 

Hope this will help you .

 

Thanks