magento 2 run indexer cli code example
Example 1: magento 2 reindex command line
bin/magento indexer:reindex
Example 2: set indexer mode command line magento 2
bin/magento indexer:set-mode {realtime|schedule} [indexer]
bin/magento indexer:reindex
bin/magento indexer:set-mode {realtime|schedule} [indexer]