January 2, 2021
Estimated Post Reading Time ~

Rebuild Indexes in AEM with OAK Index Manager

Looking to rebuild indexes in Adobe Experience Manager? Need to boost query performance? Apart from optimized code, indexing plays a very important role in an application running smoothly. If you have more queries, you need to index your nodes in order to quickly get a response.

In a recent project, I found a problem related to performance. The issue occurred when I was querying AEM, and the server responded slowly.

Before AEM 6, Jackrabbit was used, and it would index content by default. AEM 6.0 and onward, OAK repository is used, and indexes need to be created when necessary.

If you see a warning message in logs like the one below, it means indexing needs to be done for those nodes:

WARN Traversed 1000 nodes with filter Filter(query=select …) consider creating an index or changing the query

You can use the following tool to define the index for a query: http://oakutils.appspot.com/generate/index

If nodes are not indexed, it can create problems in production systems, making the system VERY slow. I faced this issue with one of my clients, where we had a large number of DAM assets, and searching for assets through Asset Search in AEM was making the system incredibly slow – sometimes even bringing the server down.

To solve this problem, we found that DAM asset nodes need to be indexed. This allows the query to respond much faster.

Below are the steps we followed to index DAM nodes:
  • In CRXDE, open this node: /oak:index/damAssetLucene
  • Make sure that in /oak:index/damAssetLucene/jcr:content, there is a property: evaluatePathRestrictions = true
  • Create properties under “/oak:index/damAssetLucene/indexRules/dam:Asset/properties,” which can be used for searching assets in DAM. See screenshot below.
  • Go to /oak:index/damLucene and change reindex property to true
  • After saving the change, the indexing will be triggered immediately
You can monitor the process in the AEM log. For example, in the terminal, use the following command to monitor whether the index has finished:

tail -f /apps/aem/crx-quickstart/logs/error.log|grep “Reindexing (async) completed”

When the index is done, you will see the following message.


How to Reindex
If a reindex is needed in the future, you can use the following approaches.
Approach 1: Reindex using CRXDE Lite
Change the reindex property to true
Save the change

The reindex will trigger immediately. After re-indexing is complete, the reindex property will automatically change back to false.

Approach 2: Reindex using OAK Index Manager
  • Download and install OAK Index Manager through https://adobe-consulting-services.github.io/acs-aem-commons/
  • Access OAK Index Manager through http://host:port/etc/acs-commons/oak-index-manager.html
  • Reindex
Any other tips around this topic, or questions? Feel free to leave a comment below


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.