reindexing magento 2 ssh cli
How to reindex your Magento 2 store from admin or SSH / CLI
Go to System > Index Management and check indexers status
2. Select the items that are marked as "Reindex required" and go to Actions > Update on schedule
This will trigger a reindex for selected indexers.
Important: Sometimes not all indexers are reindexed using admin reindex even if time & date is showing as updated in magento admin. We recommend to double check the reindex process using the SSH/CLI reindex method presented below.
Reindex mode: You can set your indexers as "Update on Save" and store entities will be indexed when saving admin configurations or as "Update by Schedule" and indexers will be reindexed recurrently (default once / day) . In order for "Update by Schedule" to work ok, make sure your cron jobs are running correctly on your server. Your hosting partner or development team can help you with the cron jobs configuration.
b. Reindex via SSH / CLI (recommended)
1. Connect to your Magento 2 installation in the root of your project. (usually in public_html or under yourmagentoinstallation.com/html)
2. Reindex all Magento 2 indexers using below command:
php bin/magento indexer:reindex
3. Check the status of the indexers and identify indexers that still need to be individually reindexed, sometimes general reindex does not work for all indexers
php bin/magento indexer:status
4. Show the list of the indexers and corresponding indexer id that need to be used for individual reindex.
php bin/magento indexer:info
5. Reindex each indexer that has status "Reindex required" using below command:
php bin/magento indexer:reindex [catalog_category_flat]
Example: php bin/magento indexer:reindex catalogrule_rule
6. Check again the status of the indexers using the command from step 2, now all indexers should be "Ready".