コード例 #1
0
 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.";
 }
コード例 #2
0
ファイル: Module.php プロジェクト: gromver/yii2-platform
 /**
  * @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);
 }
コード例 #3
0
 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);
 }