diff --git a/src/Engine/ElasticsearchEngine.php b/src/Engine/ElasticsearchEngine.php index b2b46f9..14210fd 100644 --- a/src/Engine/ElasticsearchEngine.php +++ b/src/Engine/ElasticsearchEngine.php @@ -66,6 +66,7 @@ public function update($models): void $update = [ '_id' => $model->getKey(), '_index' => $model->searchableAs(), + ...$this->appendType(), ]; } $params['body'][] = ['update' => $update]; @@ -97,6 +98,7 @@ public function delete($models): void $delete = [ '_id' => $model->getKey(), '_index' => $model->searchableAs(), + ...$this->appendType(), ]; } $params['body'][] = ['delete' => $delete]; @@ -287,4 +289,15 @@ protected function sort($builder) return [$order['column'] => $order['direction']]; })->toArray(); } + + protected function appendType(): array + { + if (version_compare(static::$version, '7.0.0', '<')) { + return [ + '_type' => 'doc', + ]; + } + + return []; + } }