Sphinx\SphinxClient::setFieldWeights PHP Method

setFieldWeights() public method

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

Usage Example

Example #1
0
 public function testSetFieldWeights()
 {
     $sphinx = new SphinxClient();
     $sphinx->setFieldWeights(array('field1' => 10, 'field2' => 200));
     $this->assertSame($sphinx->fieldweights, array('field1' => 10, 'field2' => 200));
 }
All Usage Examples Of Sphinx\SphinxClient::setFieldWeights