Ruflin Elastica RandomScore和setSort

时间:2019-05-23 09:21:22

标签: symfony elasticsearch elastica foselasticabundle

我有这个查询

$boolQuery = new \Elastica\Query\BoolQuery();
$visibleQuery = new \Elastica\Query\Terms();
$visibleQuery->setTerms('visibleAndNotDeleted', array(true));
$boolQuery->addMust($visibleQuery);

....

$score = new Query\FunctionScore();

$score->setRandomScore(crc32($this->container->get('session')->getId()));

$finalQuery = $score->setQuery($boolQuery);

$filter = new Query\Term(array('price' => 4.5));

对于此查询,我需要添加(我可以在其中添加或如何添加排序优先级的rand())

$finalQuery->setSort(
    array(
        'priority' => array('order' => 'desc'),
    )
);

所以我希望得到

ob1.priority = 100

随机 ob2.priority = 50 ob3.priority = 50

ob4.priority = 10

0 个答案:

没有答案