本文整理汇总了PHP中Elastica\Query::setRescore方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setRescore方法的具体用法?PHP Query::setRescore怎么用?PHP Query::setRescore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elastica\Query
的用法示例。
在下文中一共展示了Query::setRescore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testQuery
public function testQuery()
{
$query = new Query();
$mainQuery = new Match();
$mainQuery = $mainQuery->setFieldQuery('test1', 'foo');
$secQuery = new Term();
$secQuery = $secQuery->setTerm('test2', 'bar', 2);
$queryRescore = new QueryRescore($secQuery);
$queryRescore->setWindowSize(50);
$queryRescore->setQueryWeight(0.7);
$queryRescore->setRescoreQueryWeight(1.2);
$query->setQuery($mainQuery);
$query->setRescore($queryRescore);
$data = $query->toArray();
$results = $this->_index->search($query);
$response = $results->getResponse();
$this->assertEquals(true, $response->isOk());
$this->assertEquals(0, $results->getTotalHits());
}
示例2: testSetRescoreToArrayCast
/**
* @group unit
*/
public function testSetRescoreToArrayCast()
{
$query = new Query();
$rescore = new \Elastica\Rescore\Query();
$rescore->setQueryWeight(1);
$query->setRescore($rescore);
$rescore->setQueryWeight(2);
$anotherQuery = new Query();
$anotherQuery->setRescore($rescore);
$this->assertEquals($query->toArray(), $anotherQuery->toArray());
}