diff --git a/src/ElasticquentPaginator.php b/src/ElasticquentPaginator.php index 84de151..034eb84 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 = isset($total['value']) ? $total['value'] : $total; $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); 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, ];