algolia / instantsearch

āš”ļø Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.59k stars 503 forks source link

Wildcard facet retrieval not working in react-instantsearch #6202

Open giovanni-d opened 1 month ago

giovanni-d commented 1 month ago

šŸ› Current behavior

When using the wildcard property to retrieve all facets *, the facets are not being returned by the useInstantSearch() hook.

Screenshot 2024-05-16 at 17 00 13

When using the js library search function, you can retrieve all facets using wildcard. see codesandbox for repro.

This is also the same behavior on v6 using connectStateResults:

https://codesandbox.io/p/sandbox/algolia-facets-v6-5hn9rn?file=%2Fsrc%2FApp.tsx

šŸ” Steps to reproduce

  1. Setup instant search:
  <InstantSearch
      searchClient={searchClient}
      indexName="instant_search"
      routing={true}
      insights={true}
    >
      <Configure ruleContexts={[]} facets={["*"]} />
      <SearchState />
 </InstantSearch>
  1. Use hook useInstantSearch() to retrieve results
  2. Check the facets retrieved and it will be empty

Live reproduction

https://codesandbox.io/p/sandbox/algolia-facets-issue-9xpw2d?file=%2Fsrc%2FApp.tsx

šŸ’­ Expected behavior

Expecting to receive all facets available when using the wildcard property just like when you can retrieve them using the js client.

Package version

"algoliasearch": "4.23.2", "instantsearch.js": "4.68.1", "react": "18.2.0", "react-dom": "18.2.0", "react-instantsearch": "7.8.1"

Operating system

macOS 12.7

Browser

Chrome Version 124.0.6367.208

Code of Conduct

Haroenv commented 1 month ago

This has indeed always been the case, facets retrieved from the SearchResults class are only those that are manually set, as they require a second query if anything is refined.

You can however read the facets (which would be conjunctive) from rawResults.