Skip to content

Commit

Permalink
elasticsearch 7.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
Yavuz Selim Bilgin committed Aug 13, 2019
1 parent b68cb0a commit f7934e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Console/ElasticMakeIndicesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function handle()
$this->info("- Creating mapping for: {$type}");
$client->indices()->putMapping([
'index' => $index,
'include_type_name' => true,
'type' => $type,
'body' => [
'properties' => $mapping
Expand Down
11 changes: 8 additions & 3 deletions src/ElasticsearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public function paginate(Builder $builder, $perPage, $page)
'size' => $perPage,
]);

$result['nbPages'] = $result['hits']['total'] / $perPage;
$total = is_integer($result['hits']['total']) ? $result['hits']['total'] : $result['hits']['total']['value'];

$result['nbPages'] = $total / $perPage;

return $result;
}
Expand Down Expand Up @@ -231,7 +233,9 @@ public function mapIds($results)
*/
public function map($results, $model)
{
if (is_array($results['hits']['total']) && count($results['hits']['total']) === 0) {
$total = is_integer($results['hits']['total']) ? $results['hits']['total'] : $results['hits']['total']['value'];

if ($total === 0) {
return Collection::make();
}

Expand Down Expand Up @@ -259,6 +263,7 @@ public function map($results, $model)
*/
public function getTotalCount($results)
{
return $results['hits']['total'];
$total = is_integer($results['hits']['total']) ? $results['hits']['total'] : $results['hits']['total']['value'];
return $total;
}
}

0 comments on commit f7934e3

Please sign in to comment.