public function actionSuggest($q, $version = null, $language = null) { if (!in_array($version, $this->getVersions())) { $version = null; } if (!in_array($language, array_keys($this->getLanguages()))) { $language = null; } /** @var Command $command */ $command = Yii::$app->elasticsearch->createCommand(); $command->index = SearchActiveRecord::index() . '-en'; $result = $command->suggest(['my-suggestion' => ['text' => $q, 'term' => ['field' => 'body']]]); Yii::$app->response->format = Response::FORMAT_JSON; if (!$result) { return []; } else { return $result; } }
public static function index() { return parent::index() . '-en'; }