Elastica\Query\FunctionScore::setRandomScore PHP Method

setRandomScore() public method

If set, this query will return results in random order.
public setRandomScore ( integer $seed = null )
$seed integer Set a seed value to return results in the same random order for consistent pagination.
    public function setRandomScore($seed = null)
    {
        $seedParam = new \stdClass();
        if (!is_null($seed)) {
            $seedParam->seed = $seed;
        }
        return $this->setParam('random_score', $seedParam);
    }

Usage Example

Example #1
0
 /**
  * Get a random quip
  *
  * @return ResultSet
  */
 public function getRandom()
 {
     $fs = new FunctionScore();
     $fs->setRandomScore();
     $query = new Query($fs);
     $query->setFrom(0)->setSize(1)->setFields($this->defaultFields());
     return $this->doSearch($query);
 }
All Usage Examples Of Elastica\Query\FunctionScore::setRandomScore