Elastica\Query\Indices::addIndex PHP Метод

addIndex() публичный Метод

Adds one more index on which this query should be applied.
public addIndex ( string | Index $index )
$index string | Elastica\Index
    public function addIndex($index)
    {
        if ($index instanceof ElasticaIndex) {
            $index = $index->getName();
        }
        return $this->addParam('indices', (string) $index);
    }

Usage Example

Пример #1
0
 /**
  * @group unit
  */
 public function testAddIndex()
 {
     $client = $this->_getClient();
     $index = $client->getIndex('someindex');
     $query = new Indices(new Term(array('color' => 'blue')), array());
     $query->addIndex($index);
     $expected = array($index->getName());
     $this->assertEquals($expected, $query->getParam('indices'));
     $query->addIndex('foo');
     $expected = array($index->getName(), 'foo');
     $this->assertEquals($expected, $query->getParam('indices'));
     $returnValue = $query->addIndex('bar');
     $this->assertInstanceOf('Elastica\\Query\\Indices', $returnValue);
 }