Skip to content

Commit

Permalink
fix: merge options into query parameters for Algolia4 search
Browse files Browse the repository at this point in the history
  • Loading branch information
MingJen committed Dec 3, 2024
1 parent a4c48ac commit c8774cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/Engines/Algolia4Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,11 @@ protected function performSearch(Builder $builder, array $options = [])
);
}

$queryParams = ['query' => $builder->query];
$queryParams = array_merge(['query' => $builder->query], $options);

return $this->algolia->searchSingleIndex(
$builder->index ?: $builder->model->searchableAs(),
$queryParams,
$options
$queryParams
);
}
}
9 changes: 3 additions & 6 deletions tests/Feature/Engines/Algolia4EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public function test_search_sends_correct_parameters_to_algolia()

$this->client->shouldReceive('searchSingleIndex')->once()->with(
'users',
['query' => 'zonda'],
['numericFilters' => ['foo=1']]
['query' => 'zonda', 'numericFilters' => ['foo=1']],
);

$builder = new Builder(new SearchableUser, 'zonda');
Expand All @@ -124,8 +123,7 @@ public function test_search_sends_correct_parameters_to_algolia_for_where_in_sea

$this->client->shouldReceive('searchSingleIndex')->once()->with(
'users',
['query' => 'zonda'],
['numericFilters' => ['foo=1', ['bar=1', 'bar=2']]],
['query' => 'zonda', 'numericFilters' => ['foo=1', ['bar=1', 'bar=2']]],
);

$builder = new Builder(new SearchableUser, 'zonda');
Expand All @@ -140,8 +138,7 @@ public function test_search_sends_correct_parameters_to_algolia_for_empty_where_

$this->client->shouldReceive('searchSingleIndex')->once()->with(
'users',
['query' => 'zonda'],
['numericFilters' => ['foo=1', '0=1']]
['query' => 'zonda', 'numericFilters' => ['foo=1', '0=1']],
);

$builder = new Builder(new SearchableUser, 'zonda');
Expand Down

0 comments on commit c8774cb

Please sign in to comment.