Skip to content

searchForFacetValues -> requestOptions ? #752

Closed

Description

@vincent-eleanor-wine

Hi there,

I am doing a a search query with the version 3.4.

On the search query with filters parameter all fine, it retrieves the facet values and here works perfect.

`$vintageProducts = $this->vintageProductSearchableRepository->search($searchStringWithoutIntegers,
function (SearchIndex $algolia, string $query, array $options) use ($requestedUserOrganisation, $visibleDate, $requestedFilterCriteria, $filters, $orderByCustomAttributes,$requestedSearchFacets, $facetFilters)
{
/**
* Facets
*/

            $options['facets'] = array_keys(AlgoliaVintageProductAttributeEnum::getFacetsAttributes());

            /**
             * Filters
             */
            if($filters)
            {
                $options['filters'] = implode(' AND ', $filters);
            }

            return $algolia->search($query, $options);
        }
    );`

Although wanted to search on a certain facet so I use the same index but the searchForFacetValues and here I can search on facet values, but I want to pass the current filters so the filter is applied to the index and the facets are filtered also.

For the search parameter I pass the $requestOptions in the second parameter of the search call (return $algolia->search($query, $options)) but for the searchForFacetValues third parameter public function searchForFacetValues($facetName, $facetQuery, $requestOptions = []) this is not working for me.

` $visibleDate = new \DateTime();
$options['filters'] = OfferedVintageProductsFilterHelper::organisationOfferedVintageProductsOfferCriteriaToAlgoliaFilterArray($requestedUserOrganisation->getOrganisation(), $this->request, $visibleDate);
$indexResponse = $index->searchForFacetValues($searchableAlgoliaVintageProductAttributeEnum->value, $searchString, $options);

    $responseFacetHits = $indexResponse['facetHits'] ?? [];`

Any idea how to do this?

Kind regards,
Vincent

Activity

  1. vincent-eleanor-wine commented on Nov 5, 2025

    @vincent-eleanor-wine
    Author

    Never mind, this is working I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions