3.2. Configuring Invocation of Indexing Process

You can use the framework’s scheduled tasks mechanism to invoke the indexing process on a scheduled basis.

First, you will need to activate the task starting functionality itself. Add the following property to the app.properties file of the project core module:

cuba.schedulingActive = true

Restart the application server, log into the system as admin, open the JMX Console screen, find and open the app-core.cuba:type=Scheduling JMX bean and make sure that the Active attribute is set to true.

Then open the AdministrationScheduled Tasks screen, click Create and fill in the following attribute values for a new task:

  • Defined by: Bean

  • Bean name: cuba_FtsManager

  • Method name: processQueue()

  • Singleton: false

  • Period, sec: 30

Save the task, select it in the table and click Activate. From now on, the system will start indexing changed entities every 30 seconds.

Tip

If you have a cluster of application servers, each server that provides search functionality should maintain its own copy of the index. For this purpose, do the following:

  1. List all cluster members in the fts.indexingHosts application property.

  2. Make sure the indexing task configured above is not Singleton.

After that, changes will be queued separately for each server, and servers will pull their own records from the queue and update their indexes.

Warning

Automatic indexing does not cover the entities created before its start. To put such entities to the indexing queue use reindexAll() or asyncReindexAll() methods of the app-core.fts:type=FtsManager JMX bean. See Running and configuring entities reindexing.