Sphinx\SphinxClient::setIndexWeights PHP Method

setIndexWeights() public method

Bind per-index weights by name
public setIndexWeights ( array $weights ) : SphinxClient
$weights array
return SphinxClient
    public function setIndexWeights(array $weights)
    {
        foreach ($weights as $index => $weight) {
            if (!is_string($index)) {
                throw new \InvalidArgumentException('Index name must be a string.');
            }
            if (!is_int($weight)) {
                throw new \InvalidArgumentException('Index weight must be an integer.');
            }
        }
        $this->indexweights = $weights;
        return $this;
    }

Usage Example

Example #1
0
 public function testSetIndexWeights()
 {
     $sphinx = new SphinxClient();
     $sphinx->setIndexWeights(array('index1' => 20, 'index2' => 5));
     $this->assertSame($sphinx->indexweights, array('index1' => 20, 'index2' => 5));
 }
All Usage Examples Of Sphinx\SphinxClient::setIndexWeights