Please refer some of the best approaches and recommendations:
1. Use AEM Query Builder API (Recommended)
-
AEM’s Query Builder API is powerful and flexible for searching JCR content.
-
You can restrict search under a specific path using the
pathpredicate. -
To search page content, you can use predicates like
fulltextorfulltext.relPathto search inside specific properties (likejcr:contentnodes). -
Example query predicates:
{
"path": "/content/your-site",
"type": "cq:Page",
"fulltext": "searchTerm",
"p.limit": "10"
}
-
This query looks for pages under
/content/your-sitethat containsearchTermanywhere in their content. -
You can refine
fulltext.relPathto search only injcr:contentor specific properties.
Pros:
-
Native AEM integration, well optimized.
-
Supports paging, sorting, facets.
-
Works out of the box on AEM 6.5+ and AEM as a Cloud Service.
Reference:
2. Use Apache Lucene / Oak Indexing with Custom Indexes
-
AEM’s underlying repository is Apache Jackrabbit Oak with Lucene indexing.
-
You can create custom Oak indexes to improve search performance for your use case.
-
For full content search, ensure your index includes full-text search properties and paths under your content subtree.
-
This approach works great for large sites needing faster search results and better control.
Pros:
-
High performance for large data.
-
Supports custom analyzers, tokenization.
Reference (Oak Indexing Documentation) :
- https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/deploying/deploying/queries-and-indexing
- https://jackrabbit.apache.org/oak/docs/query/indexing.html
3. Leverage Adobe Search & Promote (if licensed)
-
Adobe Search & Promote is a SaaS product integrated with AEM providing advanced search capabilities.
-
Supports relevance tuning, faceted search, synonym handling.
-
Can index entire page content and custom metadata.
-
You can restrict search scope to a content path.
Pros:
-
Powerful out-of-the-box search experience.
-
Advanced analytics and machine learning.
4. Use AEM Content Fragments or Experience Fragments Search (if applicable)
-
If your content is structured using Content Fragments or Experience Fragments, you can index and search these fragments separately.
-
Useful if your pages are heavily composed of fragments.
5. Build a Custom Search Servlet or Service
-
Build a custom Sling Servlet that:
-
Accepts search input and path.
-
Uses Query Builder API or JCR SQL2 internally.
-
Aggregates results and returns JSON.
-
-
Allows maximum flexibility for UI integration and result customization.
Additional Recommendations
-
Index important properties: Make sure the full text or relevant text properties (e.g.,
jcr:title,jcr:description,text,cq:distribute,parsystext nodes) are included in the full-text index. -
Use highlighting/snippets: Enhance UX by returning snippets of matching content.
-
Pagination: Support paging of results for performance.
-
Security: Enforce permissions so users see only authorized content.
-
Performance: Monitor query performance and tune indexes or query predicates.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.