April 1, 2020
Estimated Post Reading Time ~

How to rebuild an index in CQ5/AEM

Prerequisite: You have to stop your CQ instance (Except for AEM6 onward)

For CQ5.2X or CQ5.3 or upgraded CQ5.4 remove or rename following files or folder

1) /crx-quickstart/repository/version/copy/index*.tar
2) /crx-quickstart/repository/workspaces/crx.default/copy/index*.tar
3) /crx-quickstart/repository/workspaces/crx.default/index
4) /crx-quickstart/repository/repository/index


In some cases, you can also recreate indexes by deleting or renaming following folders and files (Some of the files and folder has nothing to do with index, they are just removed for cleaning purpose

1) /crx-quickstart/repository/shared/journal
2) /crx-quickstart/repository/workspace/crx.default/index
3) /crx-quickstart/repository/workspace/crx.default/copy
4) /crx-quickstart/repository/workspace/version/copy/index*
5) /crx-quickstart/repository/index
6) /crx-quickstart/repository/shared/journal/control
7) /crx-quickstart/repository/shared/version/control
8) /crx-quickstart/repository/shared/workspace/crx.default/control
9) /crx-quickstart/logs


For CQ5.4 / CRX2.2 / CQ5.5 / CRX2.3 remove or rename following files and folders

1) /crx-quickstart/repository/workspaces/crx.default/index
2) /crx-quickstart/repository/workspaces/crx.default/index*.tar
3) /crx-quickstart/repository/version/index*.tar
4) /crx-quickstart/repository/tarJournal/index*.tar
5) /crx-quickstart/repository/repository/index


For AEM6 onward (If you are using oak MK), Rebuilding indexes can happen while the system is running (Note that query would not run faster if you do reindex)

Please read https://docs.adobe.com/docs/en/aem/6-0/deploy/upgrade/queries-and-indexing.html and https://docs.adobe.com/docs/en/aem/6-1/deploy/best-practices/best-practices-for-queries-and-indexing.html before doing re-indexing.

I think the best way to do reindexing in AEM6 is to use this tool http://adobe-consulting-services.github.io/acs-aem-commons/features/oak-index-manager.html

for doing full indexing of repo in AEM6 you can set reindex to true at oak: index node. More info is here http://jackrabbit.apache.org/oak/docs/query.html

If you don't have access to install this tool then you can manually go to crxde repo and set reindex property to true for the property you want to reindex (This is an expensive operation, don't do it if you don't know what you are doing).

In some cases, you need to stop your system remove/rename repository/index folder and then start the instance again



Note: In some cases, if your repository size is huge, It could take days to rebuild Lucene index. So Before you rebuild your index, make sure that you can afford that much of downtime.

Also, read
1. Which index is what in CQ/CRX

> /repository/repository/index
Lucene Search Index for jcr:system (includes jcr:versionStorage)

> /repository/workspace/crx.default/index
Lucene Search Index for crx.default workspace

> /repository/workspace/crx.default/index*.tar
Tar PM Index for crx.default workspace

> /version/index {Version index offcourse}
Tar PM Index for version workspace

> /tarJournal/index*.tar
Tar PM Index for the cluster journal for Journal PM in 5.4

2. How to reindex Large Repository in CQ or CRX
Note: Please test this before using it.

Re-indexing a large repository may take a lot of time and cause downtime. The below procedure allows to keep the production repository operational and do the re-indexing on a backup. Downtime of the production repository is limited to the time it takes to index changes that were done on the production system while the re-indexing was performed.
Stop production repository
Create a copy of the repository to a separate machine
Start the production repository again
On the repository copy:
delete the index
start repository, which will start the indexing process
once the repository is up and running (indexing completed), stop it again
stop production repository
replace crx-quickstart/repository/workspaces/crx.default/index with the one from the copy
replace crx-quickstart/repository/revision.log with the one from the copy
rename crx-quickstart/repository/cluster_node.id to crx-quickstart/repository/cluster_node.id.orig
start production repository

At this point, the repository will apply the changes to the index that were done since the copy was made.
Once the repository is online, shut it down again.
Delete crx-quickstart/repository/cluster_node.id
Rename crx-quickstart/repository/cluster_node.id.orig to cluster_node.id


By aem4beginner

No comments:

Post a Comment

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