$query =
$this->database
->
select('search_index', 'i'
) // Restrict the search to the current interface language.
->
condition('i.langcode',
$this->languageManager->
getCurrentLanguage()->
getId()) ->
extend(SearchQuery::
class) ->
extend(PagerSelectExtender::
class);
$query->
innerJoin('help_search_items', 'hsi', '[i].[sid] = [hsi].[sid] AND [i].[type] = :type',
[':type' =>
$this->
getType()]);
if ($denied_permissions) { $query->
condition('hsi.permission',
$denied_permissions, 'NOT IN'
);
} $query->
searchExpression($this->
getKeywords(),
$this->
getType());
$find =
$query ->
fields('i',
['langcode'
]) ->
fields('hsi',
['section_plugin_id', 'topic_id'
]) // Since SearchQuery makes these into GROUP BY queries, if we add
// a field, for PostgreSQL we also need to make it an aggregate or a
// GROUP BY. In this case, we want GROUP BY.
->
groupBy('i.langcode'
) ->
groupBy('hsi.section_plugin_id'
) ->
groupBy('hsi.topic_id'
) ->
limit(10
)