From 7898feb9725c27b57d93ab8e63ff5bc10e4abae8 Mon Sep 17 00:00:00 2001 From: devviettv <68636752+devviettv@users.noreply.github.com> Date: Thu, 12 Aug 2021 14:14:07 +0700 Subject: [PATCH 1/3] update paginate change paginate for elasticsearch 7.x --- src/ElasticquentPaginator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ElasticquentPaginator.php b/src/ElasticquentPaginator.php index 84de151..bbdb6b2 100644 --- a/src/ElasticquentPaginator.php +++ b/src/ElasticquentPaginator.php @@ -20,9 +20,9 @@ public function __construct($items, $hits, $total, $perPage, $currentPage = null foreach ($options as $key => $value) { $this->{$key} = $value; } - $this->total = $total; + $this->total = $total['value']; $this->perPage = $perPage; - $this->lastPage = (int) ceil($total / $perPage); + $this->lastPage = (int) ceil($this->total / $this->perPage); $this->currentPage = $this->setCurrentPage($currentPage, $this->lastPage); $this->path = $this->path != '/' ? rtrim($this->path, '/') . '/' : $this->path; $this->items = $items instanceof Collection ? $items : Collection::make($items); From 8b32a165442499c6a353364686c19429d1e170eb Mon Sep 17 00:00:00 2001 From: devviettv <68636752+devviettv@users.noreply.github.com> Date: Thu, 12 Aug 2021 14:41:10 +0700 Subject: [PATCH 2/3] Update ElasticquentPaginator.php --- src/ElasticquentPaginator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ElasticquentPaginator.php b/src/ElasticquentPaginator.php index bbdb6b2..034eb84 100644 --- a/src/ElasticquentPaginator.php +++ b/src/ElasticquentPaginator.php @@ -20,7 +20,7 @@ public function __construct($items, $hits, $total, $perPage, $currentPage = null foreach ($options as $key => $value) { $this->{$key} = $value; } - $this->total = $total['value']; + $this->total = isset($total['value']) ? $total['value'] : $total; $this->perPage = $perPage; $this->lastPage = (int) ceil($this->total / $this->perPage); $this->currentPage = $this->setCurrentPage($currentPage, $this->lastPage); From e77b548f6a5eb25985114c4507c3780075a4b81d Mon Sep 17 00:00:00 2001 From: devviettv <68636752+devviettv@users.noreply.github.com> Date: Wed, 25 May 2022 07:06:20 +0000 Subject: [PATCH 3/3] remove type for es ver 7.x --- src/ElasticquentTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ElasticquentTrait.php b/src/ElasticquentTrait.php index df2df3d..3d709c5 100644 --- a/src/ElasticquentTrait.php +++ b/src/ElasticquentTrait.php @@ -370,7 +370,7 @@ public function getBasicEsParams($getIdIfPossible = true, $limit = null, $offset { $params = array( 'index' => $this->getIndexName(), - 'type' => $this->getTypeName(), + // 'type' => $this->getTypeName(), ); if ($getIdIfPossible && $this->getKey()) { @@ -456,7 +456,7 @@ public static function putMapping($ignoreConflicts = false) 'properties' => $instance->getMappingProperties(), ); - $mapping['body'][$instance->getTypeName()] = $params; + $mapping['body']/*[$instance->getTypeName()]*/ = $params; return $instance->getElasticSearchClient()->indices()->putMapping($mapping); } @@ -531,7 +531,7 @@ public static function createIndex($shards = null, $replicas = null) $mappingProperties = $instance->getMappingProperties(); if (!is_null($mappingProperties)) { - $index['body']['mappings'][$instance->getTypeName()] = [ + $index['body']['mappings']/*[$instance->getTypeName()]*/ = [ '_source' => array('enabled' => true), 'properties' => $mappingProperties, ];