Skip to content

Commit

Permalink
IBX-6649: Added support for spell checking (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs authored Dec 5, 2023
1 parent e4eda7c commit 9f1c6d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib/QueryType/SearchQueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\SectionTermAggregation;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause\ContentId;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Spellcheck;
use Ibexa\Contracts\Core\Repository\Values\User\User;
use Ibexa\Contracts\Search\SortingDefinition\SortingDefinitionRegistryInterface;
use Ibexa\Core\QueryType\OptionsResolverBasedQueryType;
Expand Down Expand Up @@ -42,6 +43,10 @@ protected function doGetQuery(array $parameters): Query
$query = new Query();
if (null !== $searchData->getQuery()) {
$query->query = new Criterion\FullText($searchData->getQuery());

if ($this->searchService->supports(SearchService::CAPABILITY_SPELLCHECK)) {
$query->spellcheck = new Spellcheck($searchData->getQuery());
}
}

$criteria = $this->buildCriteria($searchData);
Expand Down
5 changes: 4 additions & 1 deletion src/lib/View/SearchViewBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ public function buildView(array $parameters): SearchView
$pagerfanta->setMaxPerPage($data->getLimit());
$pagerfanta->setCurrentPage(min($data->getPage(), $pagerfanta->getNbPages()));

$results = $this->pagerSearchContentToDataMapper->map($pagerfanta);

$view->addParameters([
'results' => $this->pagerSearchContentToDataMapper->map($pagerfanta),
'results' => $results,
'pager' => $pagerfanta,
'aggregations' => $adapter->getAggregations(),
'spellcheck' => $adapter->getSpellcheck(),
]);
}

Expand Down

0 comments on commit 9f1c6d1

Please sign in to comment.