本文整理匯總了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());
}