addSuggestion($suggestion); } } /** * Set the global text for this suggester * @param string $text * @return \Elastica\Suggest */ public function setGlobalText($text) { return $this->setParam("text", $text); } /** * Add a suggestion to this suggest clause * @param AbstractSuggest $suggestion * @return \Elastica\Suggest */ public function addSuggestion(AbstractSuggest $suggestion) { return $this->setParam($suggestion->getName(), $suggestion->toArray()); } /** * @param Suggest|AbstractSuggest $suggestion * @return \Elastica\Suggest * @throws Exception\NotImplementedException */ public static function create($suggestion) { switch(true){ case $suggestion instanceof Suggest: return $suggestion; case $suggestion instanceof AbstractSuggest: return new self($suggestion); } throw new NotImplementedException(); } }