Expand my Community achievements bar.

SOLVED

Search entire page content under certain content path - Suggests some best recommendations

Avatar

Level 2
What are the best ways to implement custom search capability that allows me to retrieve page results from a certain content path that includes the whole contents of the page?
Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @karthik-elumalai,

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 path predicate.

  • To search page content, you can use predicates like fulltext or fulltext.relPath to search inside specific properties (like jcr:content nodes).

  • Example query predicates:

{
  "path": "/content/your-site",
  "type": "cq:Page",
  "fulltext": "searchTerm",
  "p.limit": "10"
}
  • This query looks for pages under /content/your-site that contain searchTerm anywhere in their content.

  • You can refine fulltext.relPath to search only in jcr:content or 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) :
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, parsys text 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.


Santosh Sai

AEM BlogsLinkedIn


View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @karthik-elumalai,

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 path predicate.

  • To search page content, you can use predicates like fulltext or fulltext.relPath to search inside specific properties (like jcr:content nodes).

  • Example query predicates:

{
  "path": "/content/your-site",
  "type": "cq:Page",
  "fulltext": "searchTerm",
  "p.limit": "10"
}
  • This query looks for pages under /content/your-site that contain searchTerm anywhere in their content.

  • You can refine fulltext.relPath to search only in jcr:content or 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) :
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, parsys text 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.


Santosh Sai

AEM BlogsLinkedIn


Avatar

Administrator

@karthik-elumalai Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!



Kautuk Sahni