yii\elasticsearch\ActiveRecord::primaryKey PHP Method

primaryKey() public static method

The primaryKey for elasticsearch documents is the _id field by default. This field is not part of the ActiveRecord attributes so you should never add _id to the list of [[attributes()|attributes]]. You may override this method to define the primary key name when you have defined path mapping for the _id field so that it is part of the _source and thus part of the [[attributes()|attributes]]. Note that elasticsearch only supports _one_ attribute to be the primary key. However to match the signature of the [[\yii\db\ActiveRecordInterface|ActiveRecordInterface]] this methods returns an array instead of a single string.
public static primaryKey ( ) : string[]
return string[] array of primary key attributes. Only the first element of the array will be used.
    public static function primaryKey()
    {
        return ['_id'];
    }