Elastica\Query\Ids::setType PHP Method

setType() public method

Set type.
public setType ( array | string | Type $type )
$type array | string | Elastica\Type Type name or object
    public function setType($type)
    {
        if ($type instanceof ElasticaType) {
            $type = $type->getName();
        } elseif (empty($type) && !is_numeric($type)) {
            // A type can be 0, but cannot be empty
            return $this;
        }
        $this->_params['type'] = (array) $type;
        return $this;
    }

Usage Example

示例#1
0
 /**
  * @group functional
  */
 public function testSetTypeArraySearchSingle()
 {
     $query = new Ids();
     $query->setIds('4');
     $query->setType(array('helloworld1', 'helloworld2'));
     $resultSet = $this->_index->search($query);
     $this->assertEquals(1, $resultSet->count());
 }