Indexing Process in Magento 2


Indexing is how Magento transforms data such as products, categories, and so on, to improve the performance of your storefront. As data changes, the transformed data must be updated—or reindexed. Magento has a very sophisticated architecture that stores lots of merchant data (including catalog data, prices, users, stores, and so on) in many database tables. To optimize storefront performance, Magento accumulates data into special tables using indexers.

For example, suppose you change the price of an item from $4.99 to $3.99. Magento must reindex the price change to display it on your storefront.

Without indexing, Magento would have to calculate the price of every product on the fly—taking into account shopping cart price rules, bundle pricing, discounts, tier pricing, and so on. Loading the price for a product would take a long time, possibly resulting in cart abandonment.

How Magento implements indexing

The following components are involved in the indexing process:

Indexing types

Each index can perform the following types of reindex operations:

  • Full reindex, which means rebuilding all the indexing-related database tables.Full reindexing can be caused by a variety of things, including creating a new web store or new customer group.You can optionally fully reindex at any time using the command line.
  • Partial reindex, which means rebuilding the database tables only for the things that changed (for example, changing a single product attribute or price).

The type of reindex performed in each particular case depends on the type of changes made in the dictionary or in the system. This dependency is specific for each indexer.

The following figure shows the logic for partial reindexing.

Indexer status

Depending on whether an index data is up to date, an indexer status value is one of the following:

  • valid: data is synchronized, no reindex required
  • invalid: the original data was changed, the index should be updated
  • working: indexing is in progress

The Magento indexing mechanism uses the status value in reindex triggering process. You can check the status of an indexer in the Admin panel under System > New Index Management or manually using the command line.

Now refer the below process for Index Management as how it should be performed In Magento 2

Reindexing can be performed in two modes:

  • Update on Save: index tables are updated immediately after the dictionary data is changed.
  • Update by Schedule: index tables are updated by cron job according to the configured schedule.

To set these options:

  1. Log in to the Magento Admin.
  2. Click System > Index Management.
  3. Select the check box next to each type of indexer to change.
  4. From the Actions list, click the indexing mode.
  5. Click Submit.

You can also reindex from the command line.

The following figure shows an example of setting indexers to update by Schedule.

Index Management In Magento 2

Step 1:Login to Admin panel with user name and password.

Step 2:Now Click on the System > Index Management Tab From the left menu.

Step 3:Now you will see the Index Management Screen as per the screenshot given below.

Step 4:From the Dropdown in the left most corner just select the action which you want.

Step 5:After selection the action it will just look like as given below.

How to reindex Magento 2 data via SSH

In the older version of the Magento the index management is dependent on the indexer.php file which is under the shell folder, but in the Magento 2, there is no indexer.php file now it is managed by the bin/magento

1. For Checking the indexer status just use the below command:

sudo bin/magento indexer:status

2. For Checking the indexer info just use the below command:

sudo bin/magento indexer:info

3. For Reindexes all the indexes:

sudo bin/magento indexer:reindex //It will Reindexes all the indexes.

you can run the Single index process as it will take less time in comparison to the Reindexes All the indexer, Find the code below:

Also you can run single indexer process as well, suppose if you wants only to process Product EAV index then use the following command:

sudo bin/magento indexer:reindex catalog_product_attribute

//It will Reindexes Category Products indexes

Finally this way you can reindex all the indexes in magento 2