Skip to content

Commit

Permalink
check if limit is set
Browse files Browse the repository at this point in the history
  • Loading branch information
nticaric committed Oct 21, 2016
1 parent 97d18a5 commit 887010a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Engines/TNTSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ public function search(Builder $builder)
*/
public function paginate(Builder $builder, $perPage, $page)
{
$builder->limit = 1000;
$results = $this->performSearch($builder);

if ($builder->limit) {
$results['hits'] = $builder->limit;
}

$chunks = array_chunk($results['ids'], $perPage);

if (!empty($chunks)) {
Expand All @@ -115,7 +119,7 @@ public function paginate(Builder $builder, $perPage, $page)
protected function performSearch(Builder $builder)
{
$index = $builder->index ?: $builder->model->searchableAs();
$limit = $builder->limit ?: 15;
$limit = $builder->limit ?: 10000;
$this->tnt->selectIndex("{$index}.index");

return $this->tnt->search($builder->query, $limit);
Expand Down Expand Up @@ -149,7 +153,7 @@ public function map($results, $model)
return Collection::make();
}

$keys = collect($results['ids'])->values()->all();
$keys = collect($results['ids'])->values()->all();
$models = $model->whereIn(
$model->getQualifiedKeyName(), $keys
)->get()->keyBy($model->getKeyName());
Expand Down

0 comments on commit 887010a

Please sign in to comment.