index products on magento 2 code example
Example 1: magento 2 reindex
php bin/magento indexer:reindex
Example 2: set indexer mode command line magento 2
bin/magento indexer:set-mode {realtime|schedule} [indexer]
php bin/magento indexer:reindex
bin/magento indexer:set-mode {realtime|schedule} [indexer]