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 blocked HTTP requests. Most of these cases are easy to fix.

Table of Contents

How do I know that the index has not been built correctly?

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


Troubleshooting for errors 001 and 002

Errors 001 and 002 indicate that the index has got stuck for obscure reasons. The FiboSearch check system noticed that the indexer hasn’t made 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 the wp_remote_post() function, you should see the following errors:

Go to Tools Site Health in your WordPress You should see issues related to REST API or Loopback requests:

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 permitted IPs, but they forget to add the IP of the server to allow it to 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 a 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 is stuck again, run these actions manually one more time until the index is finished.

A real solution is to discover 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 the background. Sometimes these packages may take too long to process. The solution is to reduce the size of these sets.

Solution

Add the code either way:

  1. Open the functions.php file in your child theme and add the code at the end
  2. Or install the Code Snippets plugin and apply this code as a snippet.

After that, go to WooCommerceFiboSearchIndexer (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

Go to the directory /fibosearch and create an empty index.php. The path should be /fibosearch/index.php.

Reason

Some MySQL configs may have insufficient values 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 them to increase the value of the max_connections variable in your MySQL server.

Troubleshooting for error 005

Reason

The transaction takes too much time for some reason and MySQL server is disconnected before calling commit.

Solution

Contact your hosting provider and ask them to increase the value of the wait_timeout variable in your MySQL server. It should solve the source of the problem. If your hosting provider isn’t able to change MySQL variables, try to solve it in an alternative way. Follow the steps below:

Add the code either way:

  1. Open the functions.php file in your child theme and add the code at the end
  2. Or install the Code Snippets plugin and apply this code as a snippet.
add_filter( 'dgwt/wcas/indexer/searchable_set_items_count', function ( $count ) {
    return 10;
} );

Next, add a constant define ('DGWT_WCAS_INDEXER_MODE', 'sync'); to your wp-config.php file and try to rebuild the search index again.

Troubleshooting for error 006

Reason

If you have a lot of products and your MySQL server has a low max_allowed_packet variable, the chance that the index will get stuck increases.

Solution

Contact your hosting provider and ask them to increase the value of the max_allowed_packet variable in your MySQL server. This will definitely solve the problem.

Troubleshooting for other errors

Go to WooCommerceFiboSearchIndexer (tab), and carefully read the error message and proposed solutions.

Is it still not working? Write a support request.