From c8774cb8f1d48fba044c4b354807b35eda470e6a Mon Sep 17 00:00:00 2001 From: Teemo Date: Mon, 2 Dec 2024 19:15:48 +0800 Subject: [PATCH] fix: merge options into query parameters for Algolia4 search --- src/Engines/Algolia4Engine.php | 5 ++--- tests/Feature/Engines/Algolia4EngineTest.php | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Engines/Algolia4Engine.php b/src/Engines/Algolia4Engine.php index 2327e224..17bbda1c 100644 --- a/src/Engines/Algolia4Engine.php +++ b/src/Engines/Algolia4Engine.php @@ -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 ); } } diff --git a/tests/Feature/Engines/Algolia4EngineTest.php b/tests/Feature/Engines/Algolia4EngineTest.php index 3c02de3c..f13d8be5 100644 --- a/tests/Feature/Engines/Algolia4EngineTest.php +++ b/tests/Feature/Engines/Algolia4EngineTest.php @@ -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'); @@ -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'); @@ -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');