run magento reindex code example
Example 1: magento shell reindex
php -f shell/indexer.php reindexall
php shell/indexer.php --reindex catalog_product_attribute
php shell/indexer.php --reindex catalog_product_price
php shell/indexer.php --reindex catalog_url
php shell/indexer.php --reindex catalog_product_flat
php shell/indexer.php --reindex catalog_category_flat
php shell/indexer.php --reindex catalog_category_product
php shell/indexer.php --reindex catalogsearch_fulltext
php shell/indexer.php --reindex cataloginventory_stock
php shell/indexer.php --reindex tag_summary
Example 2: set indexer mode command line magento 2
bin/magento indexer:set-mode {realtime|schedule} [indexer]