How does the filter index work?
WooCommerce Product Filters has a built-in indexing system which allows the filters to work quickly for large product database, without performance issues.
Having an index means that there’s no need to do complex calculations and slow queries. When a customer uses a filters, the plugin simply looks at the indexed values which is much faster than querying the entire database.
How to trigger a re-index
WooCommerce Product Filters will automatically start the re-indexing process when you make changes which will affect the data in the index. This happens in the following situations:
- When you create or save a filter group.
- When you add, delete or update a product.
- When you add, delete or update a product taxonomy (i.e. categories, tags and global attributes).
If you make multiple changes which would trigger a re-index then the previous indexing process is aborted and a new one started. This reduces the load on your website.
What should I do while the indexing is taking place?
When the plugin is building or rebuilding the index, a message will appear in the WordPress admin informing you that the indexing process is taking place. This message will disappear once the indexing is complete.
The filters on the front end of the website may not reflect your latest changes until the indexing is complete.
You do not need to wait for the indexing process to finish. This is a background job and you can navigate away from the page without affecting the indexing process.
Technical information for developers
The indexing feature in WooCommerce Product Filters is based on the indexing in plugins like SearchWP and FacetWP, but with some improvements.
A custom database table is created and it stores all the values belonging to each filter and product on the site. This is needed because WordPress' standard method for handling queries and post meta during a search is slow.
To reduce the load on your server, the index is built in batches of 30 products at a time. This technique is used by other popular WooCommerce extensions like Memberships and Subscriptions. You can change this default using the filter from the developer documentation.
The indexing functionality relies on the Actions Scheduler component that is built into WooCommerce.
You can also access the tool by navigating to Tools → Scheduled actions. This page contains a table of default background jobs performed by WooCommerce itself, plus other plugins. Search for 'wcf' to find background jobs created by WooCommerce Product Filters.
What is the Action Scheduler:
The WooCommerce Action Scheduler helps your online store run important tasks in the background without slowing things down. It works by queuing up actions and running them at scheduled times, one by one. This keeps your site responsive while making sure important processes still happen reliably behind the scenes.
The Product Filters plugin uses the WooCommerce Action Scheduler to run an indexing task called wcf_batch_index
. This action processes products in batches to build the filter index without slowing down your website.
You can check the status of the indexing on the Action Scheduler page. In the "Arguments" column, each wcf_batch_index
action includes offset
and limit
values. The limit
controls how many products are indexed per batch, while the offset
tells the indexer where to start, skipping a set number of products to process the next group.
The "Log" column shows the status of each task. If an action fails, the error message will be recorded and displayed there, helping with troubleshooting.
While indexing is in progress, a notice appears in the WordPress admin dashboard. This notice disappears once indexing is complete. However, if an error occurs, the indexing process halts, and the notice remains. This happens because the final step didn't finish, so the message continues to display even though the indexer stopped.
To investigate or verify the state of the indexing process, go to the Scheduled Actions page and filter by action status. You can view pending, failed, or completed wcf_batch_index
tasks to better understand what's happening behind the scenes.