<

AEM Expanded Page Index Bundle

A standalone AEM bundle that extracts content from cq:Page nodes — including referenced Content Fragments — and applies the cq:Searchable mixin with search properties, enabling fulltext and semantic search via the cqSiteSearch Oak Elasticsearch index.

By default (ORIGINAL mode), search properties are written directly to the original /content nodes. An alternative MIRROR mode writes them to a shadow tree at /var/indexing/expanded-pages instead. Either way, a lightweight mirror at /var/indexing/expanded-pages is always maintained for operational tracking (dirty flags, references to included Content Fragments and pages).

Quickstart

1. Add the Maven repository to all/pom.xml

<repositories>
    <repository>
        <id>oak-indexing</id>
        <url>https://oak-indexing.github.io/maven-repository/</url>
        <snapshots><enabled>true</enabled></snapshots>
        <releases><enabled>true</enabled></releases>
    </repository>
</repositories>

2. Add a version property to the root pom.xml

<expanded.pages.version>1.7.0</expanded.pages.version>

3. Add dependency management to the root pom.xml

<dependency>
    <groupId>com.adobe.aem.indexing</groupId>
    <artifactId>expanded-page-index</artifactId>
    <version>${expanded.pages.version}</version>
</dependency>

4. Embed the bundle in all/pom.xml

In the <embeddeds> block of filevault-package-maven-plugin:

<embedded>
    <groupId>com.adobe.aem.indexing</groupId>
    <artifactId>expanded-page-index</artifactId>
    <target>/apps/your-packages/application/install</target>
</embedded>

In the <dependencies> block:

<dependency>
    <groupId>com.adobe.aem.indexing</groupId>
    <artifactId>expanded-page-index</artifactId>
</dependency>

5. Add OSGi configs to your ui.config module

The bundle embeds its own repoinit and service user mapping via Sling-Initial-Content, but in AEM Cloud Service there is a known ordering risk where the bundle can activate before the JCR Installer feeds those configs to ConfigAdmin. To guarantee reliable startup, add these two files to your project's ui.config module:

ui.config/.../osgiconfig/config/org.apache.sling.jcr.repoinit.RepositoryInitializer~expanded-page-index.cfg.json

{
  "scripts": [
    "create path (sling:Folder) /var/indexing/expanded-pages/content\n\ncreate service user expanded-page-index-service with forced path system/cq:services/expanded-page-index\n\nset principal ACL for expanded-page-index-service\n  allow jcr:read,jcr:modifyProperties,jcr:nodeTypeManagement on /content\n  allow jcr:read on /conf\n  allow jcr:all on /var\n  allow jcr:read on /oak:index\nend"
  ]
}

ui.config/.../osgiconfig/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~expanded-page-index.cfg.json

{
  "user.mapping": [
    "com.adobe.aem.indexing.expand:expanded-page-index=[expanded-page-index-service]"
  ]
}

6. Deploy the Oak indexes

The bundle requires two Oak indexes before it activates. These are deployed by Adobe into your AEM Cloud Service environment:

The bundle is a strict NOP until these two indexes are present — it is safe to deploy the bundle ahead of time and wait for index deployment. The cqSiteSearch Elasticsearch index is required for search queries to work, but is not a condition for the bundle to activate.

Upgrading to 1.7.0

Configuration

The bundle and its scheduler are both configured via a single OSGi PID com.adobe.aem.indexing.expand.service.SearchableIndexServiceImpl ("Expanded Page Index Configuration" in the OSGi Configuration Manager):

PropertyDefaultDescription
cron.expression 0/30 * * * * ? Cron expression controlling how often the scheduler triggers a run
concurrent false Allow a new run to start while a previous one is still executing
searchMode ORIGINAL Where to write cq:Searchable — ORIGINAL (on /content nodes) or MIRROR (on /var/indexing/ nodes). See Search Modes.
referencePropertyPattern fragmentPath Regex (full match) applied to property names on cq:Page subnodes to identify Content Fragment references. Adjust when your components use a non-standard property name (e.g. cfArticleReference, cf.*Reference).
contentPropertiesPropertyName elementNames Name of the sibling property that lists which fragment fields to extract (source-driven / WKND style). Set to empty to disable this strategy.
contentPropertyPattern (empty) Regex (full match) applied to property names inside the fragment's jcr:content/data/master node. All matching properties are extracted as body text (pattern-driven / Telekom style). Leave empty to disable.
applySearchableToFragments false When true, applies the cq:Searchable mixin to Content Fragment nodes directly, making CFs searchable alongside pages. See Fragment Indexing.
extractionStrategy RENDER How page body text is extracted — RENDER (render the page and extract text from the HTML) or PROPERTY_WALK (walk JCR properties via regex). See Page Extraction Strategy.
renderTimeoutMs 5000 RENDER mode only. Per-page render timeout (ms); a page exceeding this is treated as a transient failure and retried on the next scheduled run.
renderBatchSize 50 RENDER mode only. Max dirty pages processed per scheduler tick, since each render is expensive. PROPERTY_WALK processes all dirty pages in a single run.
includeReferencedPageContent false RENDER mode only. Whether components included from another page (reference components, Experience Fragments, ...) are indexed as part of the including page. By default they render nothing, so only the page's own content is indexed. See Referenced page content.
maxRetryAttempts 5 After this many consecutive extraction failures for a page, stop retrying automatically and mark it failed=true (excluded from the dirty queue) rather than let it block other pages forever. Applies to both extraction strategies.

Page Extraction Strategy

Two strategies control how a page's body text (and Content Fragment references) are extracted. Only one is active at a time, selected via extractionStrategy. RENDER is the default and needs no further configuration; PROPERTY_WALK is for finer-grained control over what gets indexed.

RENDER (default) — renders each page through Sling's own request-processing pipeline (SlingInternalRequest) and extracts text from the resulting HTML's <main> landmark (falling back to <body>). Content Fragment references are discovered automatically during the render (no referencePropertyPattern/contentPropertiesPropertyName/contentPropertyPattern config needed) — a wrapping ResourceResolver records every Content Fragment actually resolved while rendering the page and its nested includes/components. Use this when components don't expose extractable properties, or when the rendered output (not raw property values) best represents what should be searchable.

Notes on RENDER mode:

Referenced page content

A page may include components owned by another page, e.g. a reference component, or an Experience Fragment component including <xf>/master/jcr:content/root (Experience Fragments are treated like any other page). During an indexing render, a COMPONENT-scope Sling filter (ReferencedPageFilter) looks at every included component whose resource lives under another page's jcr:content. Components of the rendered page that only read other pages through the API (navigation, breadcrumb, teaser, list, ...) are not affected.

Changing this option only affects pages extracted afterwards; run rebuildMirror() (see Management) to apply it to all pages.

PROPERTY_WALK — walks the page's JCR properties and extracts text via the Content Fragment extraction strategies below (referencePropertyPattern, contentPropertiesPropertyName, contentPropertyPattern). Cheap and fast; requires components to expose text-bearing properties that the configured patterns can find. Enable it explicitly:

{
  "extractionStrategy": "PROPERTY_WALK"
}

Content Fragment extraction strategies

(Used by PROPERTY_WALK mode only — RENDER mode discovers Content Fragment references automatically, see above.)

Two strategies control how text is pulled out of referenced Content Fragments. They run independently and can be used simultaneously.

Note on contentPropertyPattern: this same regex is also used by standalone fragment indexing (applySearchableToFragments) to decide what a CF's own search document contains. Both uses answer the same question ("what is this fragment's searchable substance?") for two different destinations: here, the answer becomes content added to a referencing page; there, it becomes the fragment's own cq:searchContent. In practice a given deployment picks one of these two cases (embed content in pages, or index fragments as standalone documents), so one shared pattern is sufficient.

Example config using both strategies together:

{
  "searchMode": "ORIGINAL",
  "extractionStrategy": "PROPERTY_WALK",
  "referencePropertyPattern": "cf.*Reference",
  "contentPropertiesPropertyName": "elementNames",
  "contentPropertyPattern": "body|text|description"
}

What It Does

The bundle extracts content from cq:Page nodes (including referenced Content Fragments) and applies the cq:Searchable mixin with search properties to the target node (original or mirror, depending on mode). A lightweight mirror at /var/indexing/expanded-pages tracks operational state regardless of mode.

References

When a Content Fragment (or, with includeReferencedPageContent, another page) whose content a page includes is updated, the page is automatically re-indexed. Both kinds of reference are tracked the same way:

  1. Pages record everything they include in the references property of their mirror node (earlier versions wrote Content Fragments to fragmentReferences; it is migrated on the page's next extraction)
  2. The referenced Content Fragment's or page's mirror records the including pages in referencedBy
  3. An update of the referenced content marks all including page mirrors dirty, triggering re-extraction on the next scheduled run
  4. When a page, Content Fragment or folder is moved, its mirror subtree moves with it and the move is queued under /var/indexing/expanded-pages/moves. The next run applies queued moves first: it updates the paths of every mirror in the subtree, rewrites them in references/referencedBy on the other side, and marks the including pages dirty

This works both through real-time JCR observation and a periodic catch-up scan over all CFs (the safety net for anything the observation listener misses, e.g. a restart window) — the catch-up scan runs regardless of applySearchableToFragments, so it applies even if you only embed CF content in pages and never index fragments as standalone documents.

Search Modes

ORIGINAL (default)

cq:Searchable mixin and search properties are written to the original /content nodes. The Elasticsearch index covers /content directly.

Search query:

SELECT [cq:searchTitle], [cq:searchDescription], [jcr:path]
FROM [cq:Searchable]
WHERE ISDESCENDANTNODE('/content/mysite/us/en')
AND contains(*, 'search terms')
OPTION (INDEX TAG cqSiteSearch)

MIRROR

cq:Searchable mixin and search properties are written to mirror nodes at /var/indexing/expanded-pages. The Elasticsearch index covers /var/indexing/expanded-pages.

Search query:

SELECT [cq:searchTitle], [cq:searchDescription], [path]
FROM [cq:Searchable]
WHERE ISDESCENDANTNODE('/var/indexing/expanded-pages/content/mysite/us/en')
AND contains(*, 'search terms')
OPTION (INDEX TAG cqSiteSearch)

To switch to MIRROR mode, add an OSGi config to your ui.config:

ui.config/.../osgiconfig/config/com.adobe.aem.indexing.expand.service.SearchableIndexServiceImpl.cfg.json

{
  "searchMode": "MIRROR"
}

Fragment Indexing

By default only cq:Page nodes receive the cq:Searchable mixin. Set applySearchableToFragments: true to also index Content Fragments directly, so CF-only searches return fragments as first-class results alongside pages.

Enable via OSGi config:

{
  "applySearchableToFragments": true
}

What changes when enabled:

Where the mixin lands depends on searchMode:

ModeCF target
ORIGINAL (default)Original CF node at /content/dam/.../my-fragment
MIRRORCF mirror node at /var/indexing/expanded-pages/content/dam/.../my-fragment

Fragment body text is extracted using contentPropertyPattern only — the source-driven (elementNames) strategy requires a component context and is not available for standalone CFs. Configure a pattern to extract body content:

{
  "applySearchableToFragments": true,
  "contentPropertyPattern": "body|text|description"
}

Searching pages and fragments (ORIGINAL mode):

SELECT * FROM [cq:Searchable]
WHERE ISDESCENDANTNODE('/content')
AND contains(*, 'search terms')
OPTION (INDEX TAG cqSiteSearch)

Searching pages and fragments (MIRROR mode):

SELECT * FROM [cq:Searchable]
WHERE ISDESCENDANTNODE('/var/indexing/expanded-pages/content')
AND contains(*, 'search terms')
OPTION (INDEX TAG cqSiteSearch)

Choosing a configuration for your use case

The options above combine differently depending on what you're trying to achieve. Three common scenarios:

"I have pages and fragments, and I want both searchable — including fragments nobody references"

Set applySearchableToFragments: true. Fragment discovery scans all CFs under /content/dam, not just ones referenced by a page, so un-referenced fragments are covered too. Pick a contentPropertyPattern that matches the fields that make up a fragment's own searchable content (see the note on this pattern's dual role above).

"I want to control exactly what content fragment fields end up in a page's cq:searchContent — and avoid pulling in generic/shared fragment content"

Set extractionStrategy to PROPERTY_WALK and use contentPropertiesPropertyName (source-driven / WKND style) rather than contentPropertyPattern. contentPropertiesPropertyName requires each component to explicitly declare the fragment fields it renders — the most precise option, since it can't accidentally pick up a field just because its name matches a broad regex. contentPropertyPattern is coarser (any field matching the pattern is pulled in, across every CF model), which is easier to set up but easier to over-match generic/shared fields with. Avoid RENDER mode for this goal — it extracts whatever text is inside <main> on the rendered page, with no per-field control at all.

"I just want my pages searchable, including whatever text comes from the fragments they use — I don't need fragments searchable on their own"

Leave applySearchableToFragments at its default (false). Either extraction strategy works, but they differ in setup cost:

So RENDER is the zero-config path for this use case; PROPERTY_WALK gives you more control (see the previous scenario) at the cost of having to configure it correctly for your components and CF models.

Search Properties

Both modes expose the same properties on the cq:Searchable node:

PropertyDescription
cq:searchTitlePage title
cq:searchDescriptionPage description
cq:searchContentExtracted page body (multi-value, HTML stripped)

In ORIGINAL mode these sit on the /content/... page node. In MIRROR mode they sit on the corresponding /var/indexing/expanded-pages/... mirror node.

Mirror structure (operational tracking)

The mirror at /var/indexing/expanded-pages is always maintained regardless of mode. It holds operational state only — no search properties in ORIGINAL mode.

/var/indexing/expanded-pages/
├── state/
│   └── lastRun              (timestamp of last successful extraction run)
├── moves/                   (moves awaiting the next run: from, to)
└── content/                 (mirrors /content)
    └── mysite/
        └── us/
            └── en/
                └── page/    (cq:PageMirror)
                    ├── path                 = "/content/mysite/us/en/page"
                    ├── dirty                = false
                    ├── references           = ["/content/dam/fragments/...", "/content/other/page"]
                    ├── referencedBy         = ["/content/including/page"]
                    ├── extractedVia         = "RENDER" | "PROPERTY_WALK"
                    ├── retryCount           = 0      (consecutive extraction failures)
                    └── failed               = false  (true once retryCount reaches maxRetryAttempts)

Management

The bundle exposes a JMX MBean for operational tasks.
Navigate to: http://localhost:4502/system/console/jmx → com.adobe.aem.indexing.expand → ExpandedPageIndexService

OperationDescription
runExtraction()Process pages changed since the last run
rebuildMirror()Delete the mirror and rebuild from scratch
clearMirror()Delete the mirror without rebuilding
listFailedPages()List the /content paths of pages marked failed=true
retryFailedPages(pathPrefix)Re-queue failed pages at or under pathPrefix (resets failed, retryCount, and marks them dirty)
AttributeDescription
LastRunTimeTimestamp of the last successful extraction run, or Never
MirrorStatstotalPages, totalFragments, and lastRunTime
MirrorBasePath/var/indexing/expanded-pages
FailedPageCountNumber of pages currently marked failed=true

Troubleshooting

Bundle does not start — extractionService unsatisfied

The ExpandedPageIndexScheduler depends on ExpandedPageIndexService. If the service component is unsatisfied, check it directly in the OSGi console and look for any unsatisfied references there.

Bundle starts but logs "Cannot derive user name"

The service user mapping was not processed before the bundle activated. Add the ServiceUserMapperImpl.amended config to your ui.config module as described in Quickstart step 5.

Bundle starts but mirror is empty

Cause: Oak indexes not yet deployed.
Check: Browse to /oak:index/cqPageMirror-1-custom-1 in CRXDE. If missing, the indexes have not been deployed yet. The bundle logs "Oak indexes not yet available" each scheduler cycle until they exist.

Bundle starts, indexes exist, but extraction never runs

Look for "Content extraction service activated" in error.log. If absent, the service user expanded-page-index-service may not have been created by the bundle's repoinit script. Check for repoinit errors at startup.

Elasticsearch index is empty

  1. Confirm the cq:Searchable mixin is present on target nodes (CRXDE — check a /content page in ORIGINAL mode, or a /var/indexing/expanded-pages mirror node in MIRROR mode)
  2. Confirm the elastic-async lane is running — check IndexStats for elastic-async in the JMX console
  3. Confirm a cqSiteSearch index exists under /oak:index and has type=elasticsearch

Searches return no results

  1. Confirm the Elasticsearch index contains documents (check via the Oak Query Diagnostics or ES API)
  2. Confirm the search path in your query matches the mode — /content/... for ORIGINAL, /var/indexing/expanded-pages/... for MIRROR
  3. Confirm OPTION (INDEX TAG cqSiteSearch) is present in your query

Pages not updating after content changes

RENDER mode: pages stuck retrying / never indexed

Moved pages not indexed at their new location

Moves are picked up through JCR observation. A move made while the bundle isn't listening (e.g. the instance stops mid-move) may not be caught by the catch-up scan, leaving the mirror at the old path. If that happens after a large move, run rebuildMirror() (see Management).

Help

If you have any issues or questions, please open a ticket.