Open MiguelAngelGarciaGomez opened 2 years ago
What I think is the issue here is that unlike the regular search requests done by InstantSearch, which use the method search
and have all information in data
, your method includes the facet name in the url, and thus isn't in data (the only item used for the cache key). There's a way to solve this by using searchClient.search([{ indexName: this.config.indexName, type: 'facet', params: { facetName: attributeName, facetQuery: '' }}])
, as all cache data will be in "data" then and thus correctly cached
We are using
angular-instantsearch
(v 4.1.0) in an Angular 13 application. In a component, we are retrieving the facets like:where
this.config
is:The method
getFacetHits
is called from thengOnInit
of the component to obtain some facets by their name. When we did this without using thecreateSSRSearchClient
, using the regularalgoliasearch
it was working. But when we substituted it with the SSR version, it is obtaining the same results for every facet. So we suppose that, also according to the documentation, the request is cached. So we were wondering if the cache can be enabled. We have tried doing calling toawait this.config.searchClient.clearCache()
before the search is done, but the result is the same that without using it. We also have a look to thecreate-ssr-search-client-v4.spec.ts
test, from the code, adding the lineawait ssrSearchClient.clearCache();
between the lines 121 and 122, for the test "will cache a repeated request", but nothing happens, the test passes. Are we doing something wrong? Or missing something?UPDATE
We've found that the
transferState
object can be cleaned, something like:so the method looks like:
But we are not sure if this is the best way to do it, or this can cause some side effects.