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?
Solved! Go to Solution.
Views
Replies
Total Likes
@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 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.
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?
@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.
Hope this helps!!!
Could you please explain more on the requirement, do you want to search pages and corresponding pdfs associated with it ?
Correct. But it really just boils down to searching multiple paths regardless of type.
/content/mypages
/content/dam/mypagespdfs
Hi @AEM_Dan,
Please check this if it helps: https://stackoverflow.com/questions/29069184/how-to-use-multiple-paths-in-aem-search-component
Regards,
Santosh
Thank you. I found that post also but it's quite old so I didn't know if those methods were still valid.
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
Hope this will help you .
Thanks
Views
Likes
Replies