yii\elasticsearch\ActiveRecord::get PHP Method

get() public static method

Gets a record by its primary key.
public static get ( mixed $primaryKey, array $options = [] ) : static | null
$primaryKey mixed the primaryKey value
$options array 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 static | null The record instance or null if it was not found.
    public static function get($primaryKey, $options = [])
    {
        if ($primaryKey === null) {
            return null;
        }
        $command = static::getDb()->createCommand();
        $result = $command->get(static::index(), static::type(), $primaryKey, $options);
        if ($result['found']) {
            $model = static::instantiate($result);
            static::populateRecord($model, $result);
            $model->afterFind();
            return $model;
        }
        return null;
    }