本文整理汇总了PHP中Solarium_Client::moreLikeThis方法的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client::moreLikeThis方法的具体用法?PHP Solarium_Client::moreLikeThis怎么用?PHP Solarium_Client::moreLikeThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solarium_Client
的用法示例。
在下文中一共展示了Solarium_Client::moreLikeThis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moreLikeThis
/**
* Utilizes Solr's MoreLikeThis component to return similar pages
* @see WikiaSearchTest::testMoreLikeThis
* @param WikiaSearchConfig $searchConfig
* @return WikiaSearchResultSet
*/
private function moreLikeThis(WikiaSearchConfig $searchConfig)
{
$query = $searchConfig->getQuery(WikiaSearchConfig::QUERY_RAW);
$streamBody = $searchConfig->getStreamBody();
$streamUrl = $searchConfig->getStreamUrl();
if (!($query || $streamBody || $streamUrl)) {
throw new Exception("A query, url, or stream is required.");
}
$mlt = $this->client->createMoreLikeThis();
$mlt->setMltFields(implode(',', $searchConfig->getMltFields()))->setFields($searchConfig->getRequestedFields())->addParam('mlt.match.include', 'false')->setStart($searchConfig->getStart())->setRows($searchConfig->getRows())->setDocumentClass('WikiaSearchResult');
if ($searchConfig->getInterestingTerms() == 'list') {
$mlt->setInterestingTerms('list');
}
if ($searchConfig->getMltFilterQuery()) {
$mlt->addFilterQuery(array('query' => $searchConfig->getMltFilterQuery(), 'key' => 'mltfilterquery'));
}
if ($query !== null) {
$mlt->setQuery($query);
} else {
if ($streamBody) {
$mlt->addParam('stream.body', $streamBody);
} else {
if ($streamUrl) {
$mlt->addParam('stream.url', $streamUrl);
}
}
}
try {
$mltResult = $this->client->moreLikeThis($mlt);
} catch (Exception $e) {
$mltResult = F::build('Solarium_Result_Select_Empty');
Wikia::Log(__METHOD__, '', $e);
}
$results = F::build('WikiaSearchResultSet', array($mltResult, $searchConfig));
return $results;
}