Fixed bug that scout cannot work when using elasticsearch(which version is less than 7) without index. (#6384)

This commit is contained in:
李铭昕 2023-12-14 17:32:53 +08:00 committed by GitHub
parent 8c4e45b39f
commit 8b90b8ed89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -4,6 +4,7 @@
- [#6372](https://github.com/hyperf/hyperf/pull/6372) Fixed bug that AOP not working when using variadic parameters.
- [#6374](https://github.com/hyperf/hyperf/pull/6374) Fixed bug that `RateLimitAnnotationAspect::getWeightingAnnotation()` cannot work when using config `rate_limit.storage`.
- [#6384](https://github.com/hyperf/hyperf/pull/6384) Fixed bug that `scout` cannot work when using elasticsearch(which version is less than 7) without index.
## Added

View File

@ -66,6 +66,7 @@ class ElasticsearchEngine extends Engine
$update = [
'_id' => $model->getKey(),
'_index' => $model->searchableAs(),
...$this->appendType(),
];
}
$params['body'][] = ['update' => $update];
@ -97,6 +98,7 @@ class ElasticsearchEngine extends Engine
$delete = [
'_id' => $model->getKey(),
'_index' => $model->searchableAs(),
...$this->appendType(),
];
}
$params['body'][] = ['delete' => $delete];
@ -287,4 +289,15 @@ class ElasticsearchEngine extends Engine
return [$order['column'] => $order['direction']];
})->toArray();
}
protected function appendType(): array
{
if (version_compare(static::$version, '7.0.0', '<')) {
return [
'_type' => 'doc',
];
}
return [];
}
}