ActiveRecord.php
public static function mget(array $primaryKeys, $options = [])
    {
        if (empty($primaryKeys)) {
            return [];
        }
        if (count($primaryKeys) === 1) {
            $model = static::get(reset($primaryKeys));
            return $model === null ? [] : [$model];
        }

        $command = static::getDb()->createCommand();
        $result = $command->mget(static::index(), static::type(), $primaryKeys, $options);
        $models = [];
        foreach ($result['docs'] as $doc) {
            if ($doc['found']) {
                $model = static::instantiate($doc);
                static::populateRecord($model, $doc);
                $model->afterFind();
                $models[] = $model;
            }
        }

        return $models;
    }
public static function mget(array $primaryKeys, $options = [])
    {
        if (empty($primaryKeys)) {
            return [];
        }
        if (count($primaryKeys) === 1) {
            $model = static::get(reset($primaryKeys));
            return $model === null ? [] : [$model];
        }

        $command = static::getDb()->createCommand();
        $result = $command->mget(static::index(), static::type(), $primaryKeys, $options);
        $models = [];
        foreach ($result['docs'] as $doc) {
            if ($doc['found']) {
                $model = static::instantiate($doc);
                static::populateRecord($model, $doc);
                $model->afterFind();
                $models[] = $model;
            }
        }

        return $models;
    }
public static function mget ( array $ primaryKeys , $ options = [ ] ) { if ( empty ( $ primaryKeys ) ) { return [ ] ; } if ( count ( $ primaryKeys ) === 1 ) { $ model = static :: get ( reset ( $ primaryKeys ) ) ; return $ model === null ? [ ] : [ $ model ] ; } $ command = static :: getDb ( ) -> createCommand ( ) ; $ result = $ command -> mget ( static :: index ( ) , static :: type ( ) , $ primaryKeys , $ options ) ; $ models = [ ] ; foreach ( $ result [ 'docs' ] as $ doc ) { if ( $ doc [ 'found' ] ) { $ model = static :: instantiate ( $ doc ) ; static :: populateRecord ( $ model , $ doc ) ; $ model -> afterFind ( ) ; $ models [ ] = $ model ; } } return $ models ; }
Gets a list of records by its primary keys.

@param array $primaryKeys an array of primaryKey values
@param array $options options given in this parameter are passed to elasticsearch
as request URI parameters.

Please refer to the [elasticsearch documentation](http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html)
for more details on these options.
@return array The record instances, or empty array if nothing was found
Gets a list of records by its primary keys .