From e4ee8b14d5ab96bb6aab9272cffc519f10d619dd Mon Sep 17 00:00:00 2001 From: Mihails Krasilnikovs Date: Tue, 16 Aug 2022 11:39:30 +0300 Subject: [PATCH] Added ability get defaults index settings --- src/Index/Settings.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Index/Settings.php b/src/Index/Settings.php index 73e1ee3693..d8463a1aed 100644 --- a/src/Index/Settings.php +++ b/src/Index/Settings.php @@ -71,16 +71,24 @@ public function __construct(BaseIndex $index) * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html */ - public function get(string $setting = '') + public function get(string $setting = '', bool $includeDefaults = false) { - $requestData = $this->request()->getData(); + $queryParameters = [ + 'include_defaults' => $includeDefaults, + ]; + + $requestData = $this->request([], Request::GET, $queryParameters)->getData(); $data = \reset($requestData); if (empty($data['settings']) || empty($data['settings']['index'])) { // should not append, the request should throw a ResponseException throw new NotFoundException('Index '.$this->getIndex()->getName().' not found'); } + $settings = $data['settings']['index']; + $defaults = $data['defaults']['index'] ?? []; + + $settings = array_merge($defaults, $settings); if (!$setting) { // return all array @@ -329,7 +337,7 @@ public function getIndex(): BaseIndex * * @return Response Response object */ - public function request(array $data = [], string $method = Request::GET): Response + public function request(array $data = [], string $method = Request::GET, array $queryParameters = []): Response { $path = '_settings'; @@ -337,6 +345,6 @@ public function request(array $data = [], string $method = Request::GET): Respon $data = ['index' => $data]; } - return $this->getIndex()->request($path, $method, $data); + return $this->getIndex()->request($path, $method, $data, $queryParameters); } }