CoolCMS API

TranslationScopeFilters
in package

FinalYes

Limits a fulltext search over translations to one language; complements `FulltextFilter(['translations.name', …])`.

Without it MATCH … AGAINST over the translations join searches all languages, so the SQL fallback would find records through a translation in another language that ES (one document per language) correctly does not return.

Both conditions target the same join alias as the fulltext (JoinHelper alias cache), so WHERE t.language_id = :language AND t.active_translation = 1 AND MATCH(t.…) applies to a single translation row. activeTranslation mirrors the ES document guard (an inactive translation is not indexed).

IMPORTANT: the filters are phaseOneOnly, they only narrow the ids in phase 1. If they leaked into hydration of the to-many translations branch, the entity would arrive with a single translation.

Table of Contents

Methods

forLanguage()  : array<int, EqualFilter>

Methods

forLanguage()

public static forLanguage(string $translationsPath, int|null $languageId) : array<int, EqualFilter>
Parameters
$translationsPath : string

path to translations from the root entity (typically translations)

$languageId : int|null
Return values
array<int, EqualFilter> —

an empty array when the language is unknown (no limit is applied)

On this page

Search results