protected function addFacetQueryFilters($resultParameters, $allFacets, $keepAllFacetsOnSelection)
    {
        $facetFilters = [];

        if (!is_array($resultParameters['filter'])) {
            return $facetFilters;
        }

        $filtersByFacetName = $this->getFiltersByFacetName($resultParameters, $allFacets);

        foreach ($filtersByFacetName as $facetName => $filterValues) {
            $facetConfiguration = $allFacets[$facetName . '.'];
            $tag = $this->getFilterTag($facetConfiguration, $keepAllFacetsOnSelection);
            $filterParts = $this->getFilterParts($facetConfiguration, $facetName, $filterValues);
            $operator = ($facetConfiguration['operator'] === 'OR') ? ' OR ' : ' AND ';
            $facetFilters[] = $tag . '(' . implode($operator, $filterParts) . ')';
        }

        return $facetFilters;
    }