The search index could not be built

About 2% of FiboSearch Pro users experience issues with index building. The main reasons are server limitations or blocking HTTP requests. Most of these cases are easy to fix.

How do I know that the index is not built correctly?

Go to WooCommerce -> FiboSearch -> Indexer (tab). If the index has an issue, you should see red text “The search index could not be built.”, error code and message, and few solutions below. Here is a sample error you can see:


Troubleshooting for errors 001 and 002

Errors 001 and 002 tell that the index was stuck because of not entirely known reasons. The FiboSearch check system noticed that the indexer doesn’t make progress for a long time. There are a few known issues that could be the cause. Check them all in turn.

1. Your server can’t send an HTTP request to itself

Reason

The Indexer uses the WordPress function wp_remote_post() to build the index in the background. Sometimes the server can block this kind of request and responses with HTTP 401 Unauthorized or 403 Forbidden errors. As a result, the indexer cannot build the index.


Solution 1. What does your WordPress Site Health show?

If there is something wrong with wp_remote_post() function, you should see following errors:

Go to Tools -> Site Health in your WordPress. You should see issues related to REST API or Loopback request:

Expand descriptions of these errors and follow the instructions. Probably you will need to contact your hosting provider to solve it.


Solution 2. Is your website publicly available only for whitelisted IPs?

Add your server IP to the whitelist. That’s all. This is a common mistake when access is blocked by a .htaccess file. Developers add a list of allowed IPs, but they forget to add the IP of the server to allow make HTTP requests to itself.

2. Issue with WP-Cron

Reason

The Indexer sometimes uses WP-Cron to push forward the search index progress in some cases. WP-Cron isn’t used by the indexer on healthy WordPress, but in some cases, it will be necessary to finish the search index.

Solution

Install the Advanced Cron Manager plugin to verify if WP-Cron works correctly. You should see two actions related to the Indexer:

  1. wcas_build_readable_index_cron
  2. wcas_build_searchable_index_cron
  3. wcas_build_taxonomy_index_cron
  4. wcas_build_variation_index_cron

You can run these actions manually via Advanced Cron Manager. Then the Indexer should run. If the index stuck again, run these actions manually one more time until the index will be finished.

A real solution is to find the reason why the WP-Cron doesn’t work and fix it.

3. Too large products sets to process

Reason

Indexing products and other objects such as terms, variations etc are divided into batching and processing in background. Sometimes these packages may be too processing. The solution is to reduce size of these sets.

Solution

Add the below code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

After that, go to WooCommerce -> FiboSearch -> Indexer (tab) and rebuild the search index.

add_filter( 'dgwt/wcas/indexer/searchable_set_items_count', function ( $count ) {
    return 10;
} );
add_filter( 'dgwt/wcas/indexer/readable_set_items_count', function ( $count ) {
    return 5;
} );
add_filter( 'dgwt/wcas/indexer/taxonomy_set_items_count', function ( $count ) {
    return 10;
} );
add_filter( 'dgwt/wcas/indexer/variations_set_items_count', function ( $count ) {
    return 5;
} );

Troubleshooting for errors 003 and 004

Reason

Some MySQL config may have a too low value of max_user_connections or max_connections. You have to Increase max connections.

Solution 1. Add a constant define('DGWT_WCAS_INDEXER_MODE', 'sync'); to your wp-config.php file and try to rebuild the search index again. Then the indexer will work longer but will use fewer connections.

Solution 2. Contact your hosting provider and ask for increasing the value of the max_connections variable in your MySQL server.

Troubleshooting for other errors

Go to WooCommerce -> FiboSearch -> Indexer (tab) and carefully read the error message and proposed solutions.

Is it still not working? Write a support request.