setSuggest() public method

Add a suggest term.
public setSuggest ( Suggest $suggest )
$suggest Suggest suggestion object
 /**
  * @return \Elastica\ResultSet
  */
 public function getSuggestions()
 {
     $suggestPhrase = new Suggest\Phrase('content-suggester', 'content');
     $suggestPhrase->setText($this->data);
     $suggestPhrase->setHighlight("<strong>", "</strong>");
     $suggestPhrase->setAnalyzer('suggestion_analyzer');
     $suggestPhrase->setConfidence(2);
     $suggestPhrase->setSize(1);
     $suggest = new Suggest($suggestPhrase);
     $this->query->setSuggest($suggest);
     return $this->getSearchResult();
 }
Exemplo n.º 2
0
 /**
  * @group unit
  */
 public function testSetSuggestToArrayCast()
 {
     $query = new Query();
     $suggest = new Suggest();
     $suggest->setGlobalText('text');
     $query->setSuggest($suggest);
     $suggest->setGlobalText('another text');
     $anotherQuery = new Query();
     $anotherQuery->setSuggest($suggest);
     $this->assertEquals($query->toArray(), $anotherQuery->toArray());
 }