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.
Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 /**
  * @group functional
  */
 public function testRandomScoreWithoutSeed()
 {
     $query = new FunctionScore();
     $query->setRandomScore();
     $response = $this->_getIndexForTest()->search($query);
     $this->assertEquals(2, $response->count());
 }