本文整理汇总了PHP中Elastica\Query::setSuggest方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setSuggest方法的具体用法?PHP Query::setSuggest怎么用?PHP Query::setSuggest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Query
的用法示例。
在下文中一共展示了Query::setSuggest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSuggestions
/**
* @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();
}
示例2: testSetSuggestToArrayCast
/**
* @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());
}