Magento 2 Indexer / Reindex Usages through Command Line

Magento 2 Indexer/Reindex is a process that updates the search index for products, categories, and other data on your Magento 2 store. The index is a database that contains all the data related to your store’s products, categories, prices, and other information that helps your store’s search engine work efficiently.

The indexer is an essential part of your Magento 2 store, as it updates the search index when changes occur in your store. This process is required to ensure that your customers can find the products they want when they use the search bar or browse your store’s categories.

The Magento 2 indexer runs in the background and updates the search index for all the data stored in your Magento 2 store. It ensures that the search results for your store’s products are accurate and up-to-date. By default, Magento 2 has 13 indexers responsible for indexing various data types such as product prices, categories, and more.

In this article, we will discuss, how Indexer / Reindex works through the command line.

Show All Reindex Usages

To show all the reindex usages then open the terminal and in your Magento root directory, run the following command:

php bin/magento indexer --help


 indexer:info                              Shows allowed Indexers                                                           
 indexer:reindex                           Reindexes Data                                                                   
 indexer:reset                             Resets indexer status to invalid                                                 
 indexer:set-mode                          Sets index mode type                                                             
 indexer:show-mode                         Shows Index Mode                                                                 
 indexer:status                            Shows status of Indexer

How to Reindex Data

Run the following command to reindex the data of your Magento 2 store.

php bin/magento indexer:reindex

How to Reset indexer status to invalid

The purpose of resetting an indexer is to prepare it for reindexing. Sometimes, an indexer can become stuck in a processing state, which can cause issues with your store’s performance. In such cases, resetting the indexer can help resolve the issue by clearing any data that may be causing the indexer to get stuck.

Run the following command to reset the indexer:

php bin/magento indexer:reset

How to Show Index Mode

You can show the current index mode for your Magento 2 store by using the following command:

php bin/magento indexer:show-mode


Design Config Grid:                                Update on Save
Customer Grid:                                     Update on Save
Category Products:                                 Update on Save
Product Categories:                                Update on Save
Product Price:                                     Update on Save
Product EAV:                                       Update on Save
Catalog Search:                                    Update on Save
Stock:                                             Update on Save
Catalog Rule Product:                              Update on Save
Catalog Product Rule:                              Update on Save

How to Set index mode type

You can set the index mode for your Magento 2 store by using the following command:

bin/magento indexer:set-mode

To set the index mode for your Magento 2 store, run the following command:

bin/magento indexer:set-mode <mode>

Replace <mode> with the index mode you want to set, which can be one of the following:

  • realtime: This mode updates the index in real-time as changes are made to products, categories, or other data. This mode can cause performance issues in larger stores, as indexing can be resource-intensive.
  • schedule: This mode updates the index on a set schedule, which can be configured in the Magento 2 Admin Panel. This mode is better suited for larger stores, as it reduces the impact on server resources.
  • manual: This mode requires you to manually trigger the index update using the bin/magento indexer:reindex command. This mode is suitable for smaller stores with fewer products and categories.

For example, to set the index mode to “schedule”, you would run the following command:

bin/magento indexer:set-mode schedule

I hope this guide will be helpful to understand the usage of Magento 2 Indexer/ Reindex. Please do not hesitate to contact us through the comments section if you have any further questions.

Leave a comment

Your email address will not be published. Required fields are marked *