Expand my Community achievements bar.

SOLVED

Options and/or Best Practices Available For Building a Public Facing Search Bar for AEM Pages and Content

Avatar

Level 1

Hello everyone,

 

I want to build a public facing search bar/portal similar in style to the Google search. The bar would allow visitors to my website the ability to search AEM pages and content such as PDFs and other documents. Ideally I could build out filters on the frontend and backend to filter content, and also implement ways to promote certain content over others. 

 

I am aware of many external vendors like ElasticSearch, but since I'm using AEM (headless architecture with React) was hoping solutions existed within the AEM platform that would allow me to out together similar functionality. 

 

Really would appreciate any AEM-based suggestions anyone might have! 

 

Thank you, 

 

John

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi @jw273 To build a public-facing search portal for your AEM-powered website with functionalities similar to Google search, including filters and content promotion, you should consider the following AEM-based solutions and best practices:

1. Search Components: AEM provides out-of-the-box search components that can be utilized to create a search bar on your website. The Quick Search Component, for example, can be used to add search capabilities to a website and present search results for easy navigation by visitors. You can define the scope of the search within the content tree and set parameters such as maximum result size and minimum search term length.

2. Search Forms: Utilize AEM's search forms to create custom search experiences. As per the recommendations in Comprehensive Search, you can customize search forms appropriate to the location within AEM, adding specific search criteria and filters.

3. QueryBuilder API: The QueryBuilder API is a high-level query language used in AEM. As detailed in the Search forms made easy with the AEM querybuilder documentation, you can use this API to build efficient, authorable search forms and extend its functionalities as needed.

4. Faceted Search: Implement faceted search for granular searches of content using the Filters panel. According to the Use custom search facets documentation, you can add search predicates to customize the search functionality.

5. Content Promotion: For promoting certain content, you can customize the search algorithm or integrate with AEM's personalization features to boost specific pages or content based on various criteria.

6. Indexing PDF and Office Documents: To include PDFs and other documents in your search results, ensure that AEM is set up to index these file types. The documentation on Enabling AEM to search document security protected PDF and Microsoft Office documents may provide insights into configuring your AEM instance to index and search within such documents.

7. Repository Search: For backend search functionalities, leverage the capabilities of the AEM Forms Repository. The Working with AEM Forms Repository documentation can guide you on how to perform searches, including sorting and filtering results.

Remember to consider the performance implications of search functionalities, particularly for large content repositories. You may need to configure and optimize the search indexes in AEM to ensure that the search feature is performant and scales well with the size of your content.

View solution in original post

4 Replies

Avatar

Community Advisor

User Interface of input text box and search button - you can use front end (JS and CSS)

for search and filters you have to build backend logic

Use Querybuilder API for search functionality.

 

https://medium.com/@manumathew28.94/query-builder-aem-5869a1850c85

 

Query Builder is a high-level API built on top of the JCR (Java Content Repository) and allows for the creation of structured queries to search the AEM repository

 

--- sample code ---

Map<String, String> map = new HashMap<>();
// your path to start the search
map.put("path", "/content");
// Only to AEM pages - for DAM / assets different
map.put("type", "cq:Page"); 
// the text to search for
map.put("fulltext", "search term"); 
// limit the results to 50
map.put("p.limit", "50"); 

 

QueryBuilder builder = resourceResolver.adaptTo(QueryBuilder.class);
Session session = resourceResolver.adaptTo(Session.class);

 

Query query = builder.createQuery(PredicateGroup.create(map), session);
SearchResult result = query.getResult();

 

// Iterate of the hits
for (Hit hit : result.getHits()) {
String path = hit.getPath();
// Keep your logic for Filters or other display return strings
}

Avatar

Correct answer by
Employee

Hi @jw273 To build a public-facing search portal for your AEM-powered website with functionalities similar to Google search, including filters and content promotion, you should consider the following AEM-based solutions and best practices:

1. Search Components: AEM provides out-of-the-box search components that can be utilized to create a search bar on your website. The Quick Search Component, for example, can be used to add search capabilities to a website and present search results for easy navigation by visitors. You can define the scope of the search within the content tree and set parameters such as maximum result size and minimum search term length.

2. Search Forms: Utilize AEM's search forms to create custom search experiences. As per the recommendations in Comprehensive Search, you can customize search forms appropriate to the location within AEM, adding specific search criteria and filters.

3. QueryBuilder API: The QueryBuilder API is a high-level query language used in AEM. As detailed in the Search forms made easy with the AEM querybuilder documentation, you can use this API to build efficient, authorable search forms and extend its functionalities as needed.

4. Faceted Search: Implement faceted search for granular searches of content using the Filters panel. According to the Use custom search facets documentation, you can add search predicates to customize the search functionality.

5. Content Promotion: For promoting certain content, you can customize the search algorithm or integrate with AEM's personalization features to boost specific pages or content based on various criteria.

6. Indexing PDF and Office Documents: To include PDFs and other documents in your search results, ensure that AEM is set up to index these file types. The documentation on Enabling AEM to search document security protected PDF and Microsoft Office documents may provide insights into configuring your AEM instance to index and search within such documents.

7. Repository Search: For backend search functionalities, leverage the capabilities of the AEM Forms Repository. The Working with AEM Forms Repository documentation can guide you on how to perform searches, including sorting and filtering results.

Remember to consider the performance implications of search functionalities, particularly for large content repositories. You may need to configure and optimize the search indexes in AEM to ensure that the search feature is performant and scales well with the size of your content.

Many of these solutions appear like they are for internal users of AEM. Most of these filtering options are exposed in the AEM interface for content authors, but I don't see an effective way to expose them to site vistors. 

Avatar

Community Advisor

@jw273 

 

You should be able create an AEM Servlet that would generate the results based on Querybuilder / JCR / SQL-2 queries in AEM.

 

Since, the search is for end-users you might not be able to cache results on dispatcher. Thus, the search may become resource intensive for AEM.

 

I would also request you to fine-tune your queries and indexes to reduce the input-size on which queries have to be executed.


Aanchal Sikka