Indexing

FiboFilters uses its own tables in databases. Processed data is stored so that filtering can be performed quickly and accurately. Processing data and storing it in tables is called indexing.

When will the index be rebuilt completely?

  • after the first plugin installation
  • after every plugin update
  • after changing some settings
  • after clicking the button “Rebuild index”

When will the index be rebuilt partially?

  • after adding/deleting/updating product data, including variations and custom fields
  • after adding/deleting/updating a taxonomy term, including the product category, tag, attribute, and custom taxonomy term
  • after changing a product stock status after a new WooCommerce order is placed

The indexer listens for changes on the actions hook:

  • save_post
  • deleted_post
  • edited_term
  • created_term
  • delete_term

WP-CLI Commands

The index which stores all data necessary for the filtering process can be managed via WP-CLI commands. Below you can find all the available commands:

# Rebuilding the entire index
wp fibofilters index build [--show-logs] [--disable-parallel]
# Update or delete the indicated product in the index
# <id>: One or more IDs of product to update in index (comma-separated)
wp fibofilters index delete <id>
wp fibofilters index update <id>

# Other commands
wp fibosearch index get-info status
wp fibosearch index show-logs

Indexing programmatically using WordPress hooks

// Rebuilding the entire index. Use in later hook than plugins_loaded priority 15
do_action( 'fibofilters/indexer/build' );

// Update or delete the indicatedproducts in the index
// WARNING: These actions should be called later than init hook with priority 11
do_action( 'fibofilters/indexer/update_single', $product_id );
do_action( 'fibofilters/indexer/delete_single', $product_id );

Scheduling indexing

You can set a Scheduler in the plugin settings. Go to WooCommerceFiboFiltersIndexerScheduling indexing. By turning this option on, you can set up automatic index rebuilds with a custom frequency and timing, for example, “Every day at 3 AM”, or “Every Sunday at 5 AM”. 

Bear in mind that frequent index rebuilding is not recommended – FiboFilters constantly works in the background to update affected index parts. Every status update, such as “in stock” vs “out-of-stock” after an item was bought, will be automatically updated in the index. When is rebuild scheduling beneficial, then?

  1. When you want to edit many products at the same time, for example with the “bulk edit” option. There is a certain risk of clogging the WordPress in-built “Action scheduler”, and some of the data might get lost.
  2. When you import products on a regular basis. We recommend you rebuild the index after every import.
  3. When your page has lots of traffic, resulting in heavy fluctuation of stock status. In this case, there’s a similar risk of clogging the “Action scheduler”.
  4. When your WooCommerce doesn’t work correctly according to Site Health. Pay close attention to these errors:
    1. “Your site could not complete a loopback request”
    2. “A scheduled event is late”
    3. “A scheduled event has failed”
  5. Anytime you notice a discrepancy between the index content and your stock current state