Skip to content

Commit

Permalink
Fixed bug that scout cannot work when using elasticsearch(which ver…
Browse files Browse the repository at this point in the history
…sion is less than 7) without index. (#6384)
  • Loading branch information
limingxinleo authored Dec 14, 2023
1 parent 0252d54 commit a18768d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Engine/ElasticsearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function update($models): void
$update = [
'_id' => $model->getKey(),
'_index' => $model->searchableAs(),
...$this->appendType(),
];
}
$params['body'][] = ['update' => $update];
Expand Down Expand Up @@ -97,6 +98,7 @@ public function delete($models): void
$delete = [
'_id' => $model->getKey(),
'_index' => $model->searchableAs(),
...$this->appendType(),
];
}
$params['body'][] = ['delete' => $delete];
Expand Down Expand Up @@ -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 [];
}
}

0 comments on commit a18768d

Please sign in to comment.