Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Reindexing Content for Search and Queries in Crafter CMS

DZone's Guide to

Reindexing Content for Search and Queries in Crafter CMS

Looking to reindex the content on your CMS? Read on to learn how to reindex content you've already deployed suing Crafter CMS.

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

It is necessary from time to time to reindex content due to schema changes, migrations, and other scenarios. A bulk deployment will push all content to your index but involves several steps in addition to indexing which may not be needed. This article shows how to use the deployer to (re)index content that has already been deployed.

Reindexing the site content can be done using the reprocess feature in Crafter Deployer.

Step 1: Delete any Existing Content in the Index

curl "http://hostname:port/solr-crafter/update/?commit=true" -H "Content-Type: text/xml" -d "<delete><query>crafterSite:MYSITENAME</query></delete>"

Step 2: Invoke the Reprocessing

curl http://hostname:port/reprocess?password=MYPASSWORD&target=MYTARGET&processor=MyBeanName 


Parameter Name Description Example
hostname Deployer’s hostname localhost
port Deployer’s port. 9191 default is 9191
password Deployer password
target The name property value of a target bean in target context file. demodotcomprod
processor The bean name of a processor. For reindexing, it should be the bean name of a search update post processor registered for a target bean in target context file. (e.g. SearchUpdateFlattenXmlProcessor)

DemoDotComProdSearchProcessor


Step 3: Wait for Indexing

You will see indexing activity in the deployment log as well as entries on the server(s) running Crafter Search and Solr. Indexing activity time is dependant on the amount of content which must be re-processed.

Reindexing Content Without Disrupting Service in Production

In some scenarios, it’s not possible/appropriate to delete a live index and wait for the index to rebuild in production. Perhaps the index is driving dynamic features on the site that will break while the index is empty or being rebuilt. In these scenarios, you need a process for building the index offline and swapping it in.

Step 1: Prepare a Re-Index Core

The first step is to prepare an additional empty core on Solr where you can index the content.

Step 2: Set Up a New Deployment Context That Points to the New Core

The next step is to create a new deployment context that mimics/is a copy of the production deployment context, but that points to the “re-index” core. Note that you must restart the deployer in order for the new context to be detected.

Step 3: Content Freeze

Once you are about to start a re-index you need to freeze your authoring/editing activity. If Content is being updated in the live environment while you are rebuilding your indexes, you may miss updates. Ask your authors not to publish during your re-index process.

Step 4: Re-Index

Following the process above “Reindexing Content for Search and Queries” for re-indexing content, you want to invoke a reprocess action against your new deployment context.

Step 5: Wait

You will see indexing activity in the deployment log as well as entries on the server(s) running Crafter Search and Solr. Indexing activity time is dependant on the amount of content which must be re-processed.

Step 6: Swap Indexes

Now that indexing is complete you need to load the re-indexed content. Follow these steps:

  • In the Solr console for the core administration, click swap cores and provide the paths to the new index.

  • Once the core has reloaded, move the original core to backup.

  • Consider creating a copy of the re-indexed core with the original name and swapping it again to preserve file/folder names.

Step 7: Unfreeze Content

Now that you are certain everything is working as it should, notify your authors that they may start editing and publishing activities.

Step 8: Clean Up

Now that your process is complete you can clean up some of the artifacts created by the process.

  • The re-index core if swapped out.

  • The new deployment context.

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:
cms ,web dev ,content

Published at DZone with permission of Russ Danner, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}