/**
  * Run full reindex only when needed
  *
  * @return Enterprise_CatalogSearch_Model_Index_Action_Fulltext_Refresh
  *
  * @throws Enterprise_Index_Model_Action_Exception
  */
 public function execute()
 {
     if (Mage::helper('smile_elasticsearch')->isActiveEngine() == false) {
         parent::execute();
     } else {
         $this->_getLastVersionId();
         $this->_metadata->setInProgressStatus()->save();
         $engine = Mage::helper('catalogsearch')->getEngine();
         $index = $engine->getCurrentIndex();
         $index->prepareNewIndex();
         foreach ($index->getAllMappings() as $mapping) {
             $mapping->rebuildIndex();
         }
         $index->installNewIndex();
         $this->_updateMetadata();
         $this->_app->dispatchEvent('after_reindex_process_catalogsearch_index', array());
     }
     return $this;
 }
 /**
  * Get select for removing entity data from fulltext search table by key column ID
  *
  * @param int $storeId
  * @return array
  */
 protected function _getCleanIndexConditions($storeId)
 {
     $conditions = parent::_getCleanIndexConditions($storeId);
     $conditions[] = $this->_getWriteAdapter()->quoteInto('product_id IN (?)', $this->_productIds);
     return $conditions;
 }