CASE 07 / SEARCH / ELASTICSEARCH / INTEGRATION
AEM Elasticsearch Integration: Search Queries, Facets and Content Freshness
AEM site search needs an explicit contract between published content, the search index and the user-facing filters. This representative integration separates relevance from exact filtering and makes content freshness and dependency failures visible in the design.
Engineering path
Engineering path
Proposed engineering sequence
- 01Published content
- 02Index contract
- 03Elasticsearch
- 04Search API
- 05Facets / results
01 / Context
Start with search tasks and expected results
- PLATFORM
- Elasticsearch / AEM
- SCOPE
- Elasticsearch integration with AEM site search
- TYPE
- Representative engineering scenario
Define representative queries, exact filters, sorting and empty states before implementing the integration. External search is a deliberate product and architecture choice, not evidence that every JCR query requires replacement.
02 / THE ENGINEERING PROBLEM
Correct results and correct facet counts are separate requirements
A result list can appear plausible while its counts, publication visibility or language handling are wrong. Capture expected behavior for combinations of filters, not only a single successful keyword search.
03 / CONSTRAINTS
Boundaries the design must preserve
- Bound query inputs and define facet-count semantics explicitly.
- Keep cluster administration outside this integration scenario.
04 / ARCHITECTURE
Put an application contract between AEM and Elasticsearch
A Java service translates bounded search inputs into queries and maps results into a stable response. Define how published content reaches the index, how deletions propagate and what freshness means; no specific indexing implementation is claimed.
System boundaries
Owns user-facing external search; Oak query tuning and Elasticsearch cluster administration are outside scope.
Elasticsearch integration with AEM site search
- Published content
- Index contract
- Elasticsearch
- Search API
- Facets / results
05 / IMPLEMENTATION
Separate ranking conditions from exact constraints
Use relevance-bearing queries for text matching and filter context for exact conditions where scoring is not required. Decide whether a selected filter should affect facet counts: filtering the query and applying a post-filter have different effects on aggregations.
Implementation checkpoints
Proposed engineering checks for this scenario.
- 01Bound page sizes and validate sort and filter fields.
- 02Specify behavior for missing documents and stale links.
- 03Set dependency timeouts and a deliberate user-facing failure response.
06 / TECHNICAL DECISIONS
Document facet behavior as part of the API
Define whether counts describe the current result set or alternative selections. This decision drives query construction and prevents frontend and backend implementations from silently interpreting filters differently.
07 / TRADEOFFS
External indexing introduces a consistency boundary
Search-specific capabilities add another representation of content to maintain. Publishing and indexing are not automatically atomic, so the design needs a freshness policy and a way to diagnose divergence.
| Risk | Impact | Mitigation to validate |
|---|---|---|
| Incorrect facet scope | Plausible results but misleading counts | Use expected multi-filter fixtures |
| Stale index entries | Removed content remains discoverable | Test publication, update and deletion transitions |
To isolate the search integration from presentation, use an explicit OSGi service contract.
08 / VALIDATION
Use a small relevance and filtering fixture
Build a representative content set with expected results rather than claiming query optimization from isolated timings.
Acceptance scope and limits
TO VALIDATE
Proposed checks, not captured results.
- Check keyword, empty-query and multi-filter cases with expected counts.
- Publish, update and remove a document and inspect visibility transitions.
- Test timeout, invalid-input and zero-result behavior independently.
DOES NOT CLAIM
Owns user-facing external search; Oak query tuning and Elasticsearch cluster administration are outside scope.
- A completed customer deployment or measured production outcome
- A passing test run without retained execution evidence
09 / LESSONS LEARNED
Search quality starts with an explicit result contract
The useful engineering artifact is a set of reproducible search expectations. Cluster sizing and performance gains need separate evidence and are not asserted in this case study.
Technical references
These sources document product behavior. The scenario and proposed validation are engineering interpretations, not vendor claims or execution evidence.