Hello guys, we want to set up a client search for ...
# community-help
z
Hello guys, we want to set up a client search for Typesense so that it can cache the search result locally. This seem to be the default behavior in Algolia but not in Typesense. For example, when we have a search box for user to input the query, and it returns the full list when the search box is empty ;now when user searches for something and then clears the search box, it should return the full list again. In Algolia, when user clears the search box, it shows the fully list instantly without sending any request; but in Typesense, it sends another request to get the result... We want to achieve the same effect as it is in Algolia, what is the proper way to do this? I tried setting
cacheSearchResultsForSeconds
configuration for the client to like 1 day, but it doesn't seem to do anything.
j
May I know if you're using autocomplete.js or instantsearch.js or are you using typesense.js directly?
z
@Jason Bosco I'm using instantsearch.js in this case, wrapped with the typesense adaptor for it
so I'm passing in
cacheSearchResultsForSeconds
as
additionalSearchParameters
for the adaptor
Also pass this
cacheSearchResultsForSeconds
to the instant search adaptor: https://github.com/typesense/typesense-instantsearch-adapter, but still not seeing it's cached
j
cacheSearchResultsForSeconds
need to go inside
server.cacheSearchResultsForSeconds
and not in additionalSearchParameters
z
@Jason Bosco I also set that under
server
but it still sends a multi_search request for the same payload
@Jason Bosco Found that it's because of a re-rendering that re-creates the adaptor. I have another question... if we want to set
override_tags
for the InstantSearch component so that it can set a tag to trigger an override only when certain conditions are met, how should we do that?
I tried use the
<Configure />
widget but it doesn't seem to set the
override_tags
search parameter
Sorry I meant the
enable_overrides
parameter
j
enable_overrides
would go inside
additionalSearchParameters
z
@Jason Bosco if we want to send this parameter dynamically (i.e. when user type something) without reconfiguring the adaptor, how shall we do that? Setting it in
additionalSearchParameters
seems to reconfigure the adaptor and hence would clear the cache
j
Yup it will have to bust the cache by definition because the cache key is all the search parameters combined. So if the search parameters change, then the cache is stale
z
I see - can we configure something on the override side in the cluster, to say "if q='*', and there's no other refinement, then do this override"? In other words, we only want to perform an override when user is doing a play "q=*" search, but as soon as they apply more refinments/filters, we dont do the override
Cuz we want to re-use the cache without reconfiguring the adaptor, and seems like that's the only way to go if possible
j
This is not possible to do on the server-side unfortunately.