AJAX Search for Woocommerce plugin has own independent search index. The index is built automatically after the first plugin installation, every plugin update and after change some settings.

The later changes of products, attributes, and terms are also taken into account, so it is not required to rebuild the index after editing a product or term. Indexer listens for changes on actions hook: save_post, deleted_post, edited_term, created_term and delete_term.

To see the current status of the search index, go to WooCommerce -> AJAX Search box -> Indexer (tab).

Single document indexing

Sometimes for some reason, you need to update products in the search index programmatically. This can be done as follows:

Warning: These methods should call in 'init' or 'admin_init' hook. Not earlier.

Add/Update product

use \DgoraWcas\Engines\TNTSearchMySQL\Indexer\Updater;


Remove product

use \DgoraWcas\Engines\TNTSearchMySQL\Indexer\Updater;


Rebuild search index programmatically

Some WooCommerce stores use import tools or custom code to refresh prices or bulk add/edit products. After these tasks are good to rebuild the whole index. This can be done as follows:

use \DgoraWcas\Engines\TNTSearchMySQL\Indexer\Builder;

//To check if index is successfully created
if(Builder::getInfo('status') === 'completed'){