public function down() { $index = \gromver\platform\common\models\elasticsearch\ActiveDocument::index(); \yii\elasticsearch\ActiveRecord::getDb()->createCommand()->deleteIndex($index); //->deleteAllIndexes();// echo "Index {$index} are deleted successfully."; }
/** * @inheritdoc */ public function bootstrap($application) { $this->documentClasses = array_merge($this->documentClasses, ModuleQuery::instance()->implement('gromver\\platform\\common\\interfaces\\SearchableInterface')->fetch('getDocumentClasses', [], ModuleQuery::AGGREGATE_MERGE)); ActiveDocument::watch($this->documentClasses); }
protected function collectFilters() { $filters = []; foreach ($this->types as $type) { if ($documentClass = ActiveDocument::findDocumentByType($type)) { /** @var ActiveDocument $documentClass */ $conditions = $documentClass::filter(); foreach ($conditions as $condition) { $filters[json_encode($condition)] = $condition; } } } return array_values($filters); }