magento 2 check if job needs applied programmatically code example
Example: run partial indexing from command line magento 2
bin/magento cronmanager:runjob indexer_update_all_views
bin/magento cronmanager:runjob indexer_update_all_views