本文整理汇总了PHP中Elastica\Query::setMinScore方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setMinScore方法的具体用法?PHP Query::setMinScore怎么用?PHP Query::setMinScore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Query
的用法示例。
在下文中一共展示了Query::setMinScore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPaginatedByQueryAndCategory
/**
* @inheritdoc
*/
public function findPaginatedByQueryAndCategory(\string $queryString = null, \string $category = null, \int $priceFrom = null, \int $priceTo = null, \bool $availability = null)
{
$queryObject = new Query();
$filter = new BoolAnd();
if ($queryString) {
$query = new Match('_all', ['query' => $queryString, 'operator' => 'AND']);
} else {
$query = new Query\MatchAll();
}
if ($availability !== null) {
$filter->addFilter(new Term(['availability' => $availability]));
}
$range = [];
if ($priceFrom) {
$range['gte'] = $priceFrom;
}
if ($priceTo) {
$range['lte'] = $priceTo;
}
if ($range) {
$filter->addFilter(new Range('price', $range));
}
if ($category) {
$term = new Term(['category.id' => $category]);
$queryObject->setPostFilter($term);
}
$terms = new Terms('categories');
$terms->setField('category.id');
$terms->setSize(0);
$queryObject->addAggregation($terms);
if ($filter->getFilters()) {
$filtered = new Query\Filtered($query, $filter);
$queryObject->setQuery($filtered);
} else {
$queryObject->setQuery($query);
}
$queryObject->setSort(['updated' => 'desc']);
$queryObject->setMinScore(0.5);
return $this->findPaginated($queryObject);
}