Autocomplete searchForFacetValues with hierarchy

within autocomplete I have a few sources that use facets, and those without a hierarchy are working nicely

If I set facetName to one of the levels (see code below), I get some hits.

How can I search all levels (lvl0 … lvl3) for the query?

{
      name:"categorieshierarchy",
      source: function(query, callback) {
        hitsIndex
          .searchForFacetValues({
            facetName: "acategoryhierarchical.lvl1",
            facetQuery: query
          })
          .then(
            function(answer) {
            console.log('categorieshierarchy then answer', answer);
              callback(answer.facetHits.slice(0, 10), query);
            },
            function() {
              callback([]);
            },
            

          );
...

Hi Andrew!

It is not currently possible to search for the facet values of all levels at once, but your use case is interesting and I will pass your feedback to our product team.

For now, the best option is to choose one level where to run the search, though.

I have created 4 queries then do
Promise.all([l0, l1, l2, l3])
and then combine
var facetHits = [...answer[0].facetHits, ...answer[1].facetHits,...answer[2].facetHits, ...answer[3].facetHits];

1 Like