Skip to content

Commit

Permalink
Merge #60
Browse files Browse the repository at this point in the history
60: Added raw search (fixes #17) r=curquiza a=althaus



Co-authored-by: Matthias Althaus <kontakt@althaus.it>
  • Loading branch information
bors[bot] and althaus committed Mar 24, 2021
2 parents 52239b1 + 9140407 commit a4f62c7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ public function search(
array $requestOptions = []
): array;

/**
* Get the raw search result.
*
* @see https://docs.meilisearch.com/reference/api/search.html#response
*
* @param string $className
* @param string $query
* @param array $searchParams
*
* @return array
*/
public function rawSearch(
string $className,
string $query = '',
array $searchParams = []
): array;

/**
* @param string $className
* @param string $query
Expand Down
13 changes: 13 additions & 0 deletions src/Services/MeiliSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ public function search(
return $results;
}

/**
* {@inheritdoc}
*/
public function rawSearch(
string $className,
string $query = '',
array $searchParams = []
): array {
$this->assertIsSearchable($className);

return $this->engine->search($query, $this->searchableAs($className), $searchParams);
}

/**
* {@inheritdoc}
*/
Expand Down
11 changes: 11 additions & 0 deletions src/Services/NullSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ public function search(
return [new stdClass()];
}

/**
* {@inheritdoc}
*/
public function rawSearch(
string $className,
string $query = '',
array $searchParams = []
): array {
return [];
}

/**
* {@inheritdoc}
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/TestCase/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ public function testSearchImportAggregator()
$results = $this->searchService->search($this->objectManager, Post::class, $searchTerm);
$this->assertCount($nbEntityIndexed , $results);

$results = $this->searchService->rawSearch(Post::class, $searchTerm);
$this->assertCount($nbEntityIndexed , $results['hits']);

// clearup table
$this->connection->executeUpdate($this->platform->getTruncateTableSQL($this->indexName, true));
$this->cleanUp();
Expand Down

0 comments on commit a4f62c7

Please sign in to comment.