mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that scout
cannot work when using elasticsearch(which version is less than 7) without index. (#6384)
This commit is contained in:
parent
8c4e45b39f
commit
8b90b8ed89
@ -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
|
||||
|
||||
|
@ -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 [];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user