protected function IndexResource::applyFiltersToQuery in JSON:API Search API 8
Apply filters to the index query.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
\Drupal\search_api\Query\QueryInterface $query: The query.
\Drupal\Core\Cache\CacheableMetadata $cacheability: The cache metadata.
Throws
\Drupal\Component\Plugin\Exception\PluginException
1 call to IndexResource::applyFiltersToQuery()
- IndexResource::process in src/
Resource/ IndexResource.php - Process the resource request.
File
- src/
Resource/ IndexResource.php, line 149
Class
- IndexResource
- JSON:API Resource to return Search API index results.
Namespace
Drupal\jsonapi_search_api\ResourceCode
protected function applyFiltersToQuery(Request $request, QueryInterface $query, CacheableMetadata $cacheability) : void {
$parse_mode = $this->parseModeManager
->createInstance('terms');
assert($parse_mode instanceof ParseModeInterface);
$query
->setParseMode($parse_mode);
$filter = $request->query
->get(Filter::KEY_NAME);
if (isset($filter['fulltext'])) {
$query
->keys($filter['fulltext']);
unset($filter['fulltext']);
}
try {
$filter = Filter::createFromQueryParameter($filter);
$query
->addConditionGroup($filter
->queryCondition($query));
} catch (\Exception $exception) {
throw new CacheableBadRequestHttpException($cacheability, $exception
->getMessage());
}
}