Skip to content

Fix AEM Traversal Warnings: Find the Query, Generate an Oak Index, Deploy It

What the Oak "Traversed N nodes" warning means, how to find the slow query, generate a Lucene index, and deploy it on Cloud Service or reindex on 6.5.

Written in November 2026 for AEM as a Cloud Service and AEM 6.5. Checked against Adobe's documentation on query and indexing best practices and content search and indexing, the Apache Jackrabbit Oak query and indexing docs, and the Oak Indexing Tools site.

On this page
  1. What does the "Traversed N nodes" warning mean?
  2. How do you find the slow query?
  3. Can you fix the query instead of adding an index?
  4. Is the Oak Index Definition Generator still available?
  5. How do you deploy a custom index in AEM as a Cloud Service?
  6. How do you reindex in AEM 6.5?

A "Traversed N nodes" warning in the AEM log means Oak ran a query that no index could answer, so it walked the repository node by node and tested each one. Fixing it takes three steps: find the query and the code that ran it, make the query selective, and give it a Lucene index. On AEM as a Cloud Service the index is deployed from your code as /oak:index/<name>-custom-<n> and built by Cloud Manager. On AEM 6.5 you deploy the same definition and the index builds or reindexes on the instance.

What does the "Traversed N nodes" warning mean?

Here is the line as Adobe's query best practices for Cloud Service show it, wrapped for reading:

28.06.2022 13:32:52.804 *WARN* [127.0.0.1 [1656415972414] POST /libs/settings/granite/operations/diagnosis/granite_queryperformance.explain.json HTTP/1.1]
org.apache.jackrabbit.oak.plugins.index.Cursors$TraversingCursor
Traversed 98000 nodes with filter Filter(query=select [jcr:path], [jcr:score], * from [nt:base] as a /* xpath: //* */, path=*)
called by com.adobe.granite.queries.impl.explain.query.ExplainQueryServlet.getHeuristics;
consider creating an index or changing the query

Three parts matter. TraversingCursor says no index was used. Filter(query=...) carries the statement, both in SQL-2 and in the XPath it was translated from. called by names the Java class and method that sent it, which is your starting point in the code base. A variant reads Index-Traversed instead: an index was picked, but it still had to read a large number of nodes because it covers the conditions poorly.

The warning also has a ceiling. AEM as a Cloud Service stops a query at the traversal limit of 100,000 nodes, so a query that works on a small development repository can fail on production with an UnsupportedOperationException. AEM 6.5 behaves the same way once read limits are set, and Adobe's 6.5 indexing best practices suggest setting oak.queryLimitReads low in development (5000, for example) so these queries break early, on your machine.

How do you find the slow query?

Search the Java log. On Cloud Service, download or tail aemerror and grep for Traversed and Index-Traversed. On 6.5 the same lines are in crx-quickstart/logs/error.log.

aio cloudmanager:download-logs 67890 publish aemerror 2
grep -h -E "Traversed|Index-Traversed" *.log | grep -o "called by [^;]*" | sort | uniq -c | sort -rn

That second line counts the warnings per calling method, which shows which component or servlet to fix first.

Open the Query Performance tool. It lives at /libs/granite/operations/content/diagnosistools/queryPerformance.html; on Cloud Service you reach it through the Developer Console in Cloud Manager, on 6.5 under Tools > Operations > Diagnosis. It lists Slow Queries (those reading more than 5000 rows) and Popular Queries, each with the thread that last ran it, and its Explain Query tab shows the plan Oak chooses. Paste the statement there and look at the plan. A good plan names an index, for example lucene:damAssetLucene-9(/oak:index/damAssetLucene-9), with your conditions listed after it. A plan without an index, or with an index that matched only the path, is the one to fix.

Can you fix the query instead of adding an index?

Sometimes, and it's worth trying first because every index costs write time and storage. A query traverses when it gives Oak nothing to narrow on:

-- traverses: any node type, anywhere in the repository
SELECT * FROM [nt:base] WHERE [featured] = true

-- selective: one node type, one subtree, sorted, capped in code
SELECT * FROM [cq:PageContent] AS c
WHERE ISDESCENDANTNODE(c, '/content/wknd')
  AND c.[featured] = true
ORDER BY c.[cq:lastModified] DESC

Restrict the node type and path, sort only when the page needs it, and cap how many results you read. If the data rarely changes, compute the list when content is published and store it, so pages never query at all. When a selective query still has no index to serve featured, add one.

Is the Oak Index Definition Generator still available?

Not at its old address. The generator that older AEM posts link to, oakutils.appspot.com/generate/index, now returns a 404, and Adobe's current documentation doesn't reference it. What Adobe links to instead, from its Cloud Service indexing guide, is Oak Indexing Tools. Its Index Definition Generator takes an SQL-2 or XPath query and proposes a Lucene index definition for it.

Treat the output as a draft. Check that the node type in indexRules is the one your query selects, that includedPaths is as narrow as the content allows, and that sorted properties are marked ordered. Then give it a name that follows the rules below.

How do you deploy a custom index in AEM as a Cloud Service?

You never edit /oak:index on a running environment: the Index Manager isn't available, and every index change ships in your code. Cloud Manager builds the new index on author and publish before traffic switches to the new release. Indexes must be of type lucene, and async may only be [async], [async,nrt] or [fulltext-async].

Names carry a version. A customization of an out-of-the-box index appends -custom- and a number, so damAssetLucene-8 becomes damAssetLucene-8-custom-1. A fully custom index also needs a prefix of 2 to 5 characters and a dot: wknd.featuredPages-1-custom-1. Treat a deployed definition as immutable. To change it, deploy -custom-2; the old version stops being used and is cleaned up later. To add properties to a DAM search, customize damAssetLucene rather than creating a new index on dam:Asset, which Adobe discourages.

Option 1: Simplified Index Management (diff.index)

For any index with an includedPaths such as /content, Adobe's simpler route is one JSON file. AEM merges it with the current product indexes and creates versions itself. The folder ui.apps/src/main/content/jcr_root/_oak_index/diff.index/ needs a placeholder .content.xml:

<?xml version="1.0" encoding="UTF-8"?><jcr:root
    xmlns:jcr="http://www.jcp.org/jcr/1.0"
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:unstructured"
    type="lucene" includedPaths="/same" queryPaths="/same" async="async">
<diff.json jcr:primaryType="nt:file"/></jcr:root>

and a diff.json next to it with the index for the query above:

{
  "wknd.featuredPages": {
    "async": [ "async" ],
    "compatVersion": 2,
    "evaluatePathRestrictions": true,
    "includedPaths": [ "/content/wknd" ],
    "queryPaths": [ "/content/wknd" ],
    "selectionPolicy": "tag",
    "tags": [ "featuredPages" ],
    "type": "lucene",
    "indexRules": {
      "cq:PageContent": {
        "properties": {
          "featured": { "name": "featured", "propertyIndex": true },
          "lastModified": { "name": "cq:lastModified", "ordered": true }
        }
      }
    }
  }
}

Add <filter root="/oak:index/diff.index"/> to ui.apps/src/main/content/META-INF/vault/filter.xml and deploy. With selectionPolicy set to tag, Oak uses the index only for queries that ask for it, so other queries can't switch to it by surprise. The query therefore ends with the tag:

SELECT * FROM [cq:PageContent] AS c
WHERE ISDESCENDANTNODE(c, '/content/wknd') AND c.[featured] = true
ORDER BY c.[cq:lastModified] DESC
OPTION(INDEX TAG featuredPages)

Option 2: a versioned index definition

Indexes that cover /apps, /libs or the root can't use the diff file and stay on the older layout: one folder per index under _oak_index, named with its full version. The same index written this way goes in ui.apps/src/main/content/jcr_root/_oak_index/wknd.featuredPages-1-custom-1/.content.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
    jcr:primaryType="oak:QueryIndexDefinition"
    type="lucene"
    async="[async]"
    compatVersion="{Long}2"
    evaluatePathRestrictions="{Boolean}true"
    includedPaths="[/content/wknd]"
    queryPaths="[/content/wknd]"
    selectionPolicy="tag"
    tags="[featuredPages]">
    <indexRules jcr:primaryType="nt:unstructured">
        <cq:PageContent jcr:primaryType="nt:unstructured">
            <properties jcr:primaryType="nt:unstructured">
                <featured jcr:primaryType="nt:unstructured"
                    name="featured" propertyIndex="{Boolean}true"/>
                <lastModified jcr:primaryType="nt:unstructured"
                    name="cq:lastModified" ordered="{Boolean}true"/>
            </properties>
        </cq:PageContent>
    </indexRules>
</jcr:root>

with <filter root="/oak:index/wknd.featuredPages-1-custom-1"/> in filter.xml. Use one route or the other for a given index, not both.

Project settings both options need

The Maven build has to accept index definitions. In ui.apps/pom.xml and ui.apps.structure/pom.xml, the filevault-package-maven-plugin configuration gets <allowIndexDefinitions>true</allowIndexDefinitions> and the package property <noIntermediateSaves>true</noIntermediateSaves>, and ui.apps.structure needs a filter root for /oak:index. The top-level pom.xml lists oak:index among the immutable root node names:

<jackrabbit-packagetype>
  <options>
    <immutableRootNodeNames>apps,libs,oak:index</immutableRootNodeNames>
  </options>
</jackrabbit-packagetype>

After the pipeline runs, Explain Query in the Developer Console should name the new index for your statement.

How do you reindex in AEM 6.5?

A new index definition builds on its own once it's saved, whether it arrives in a package or is created in CRXDE. Changing an existing definition needs a rebuild. On a TarMK instance, set the reindex property of the index definition node to true:

/oak:index/wknd.featuredPages
  - reindex = true (Boolean)

Asynchronous indexes, which includes every Lucene index, start rebuilding on the next async indexing cycle, and Oak sets the flag back to false when the rebuild is done. Watch progress in error.log or in the Index Manager under Tools > Operations > Diagnosis. On MongoMK or RDBMK repositories, Adobe supports only oak-run.jar for reindexing on 6.5, and on a large repository with PDFs and Office files, text pre-extraction shortens a full-text reindex.

Migrating to the cloud, these indexes move into the -custom- naming above, and nobody sets reindex by hand again.

More in Operations, SEO and upgrades