magento2 – Magento 2 Catalog rule can not applied after reindex automatic

I wrote the code for creating a Catalog rule in Magento 2.3.5 and after saving I have the code to re-index it automatically.

  /** @var MagentoCatalogRuleModelRule $model */
                $ruleRepository = $this->_objectManager->get(
                $catalogRule = $this->_objectManager->create(MagentoCatalogRuleModelRule::class);
                $ruleByBoRefId = $this->getRuleByBoRefId($boRefId);
                if (isset($ruleByBoRefId("rule_id")) && $ruleId = $ruleByBoRefId("rule_id")) {
                    $catalogRule = $ruleRepository->get($ruleId);


Code Reindex auto:

public function reindexCatalogRule($catalogRule){


    $collection = $this->_indexerCollectionFactory->create()->getAllIds();
    foreach ($collection as $id) {
        $indexer = $this->_indexerFactory->create()->load($id);

But after reindex the Rule still doesn’t apply to the product. However, after I go to the admin and edited the previously saved catalog rule => Click Save => Then I ran the Indexer: reindex command of magento, the rule applies normally. I don’t understand why like that. Please help me
How to apply rules to products automatically ?