Sphinx\SphinxClient::setIdRange PHP Method

setIdRange() public method

Limit the ID range; only match records if document ID is between $min and $max (inclusive)
public setIdRange ( integer $min, integer $max ) : SphinxClient
$min integer minimum document ID
$max integer maximum document ID
return SphinxClient
    public function setIdRange($min, $max)
    {
        if (!is_numeric($min)) {
            throw new \InvalidArgumentException('Minimum ID must be numeric.');
        }
        if (!is_numeric($max)) {
            throw new \InvalidArgumentException('Maximum ID must be numeric.');
        }
        if ($min > $max) {
            throw new \InvalidArgumentException('Minimum ID cannot be larger than maximum ID.');
        }
        $this->minid = $min;
        $this->maxid = $max;
        return $this;
    }

Usage Example

示例#1
0
 public function testFilterIdRange()
 {
     $sphinx = new SphinxClient();
     $sphinx->setIdRange(2, 4);
     $results = $sphinx->query('bb');
     $this->assertEquals(array_keys($results['matches']), array('4', '2', '3'));
 }
All Usage Examples Of Sphinx\SphinxClient::setIdRange