Skip to content

Clear cache while search using instantsearch.js #1050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ChandanaCH opened this issue Jun 1, 2016 · 13 comments
Closed

Clear cache while search using instantsearch.js #1050

ChandanaCH opened this issue Jun 1, 2016 · 13 comments

Comments

@ChandanaCH
Copy link

Hi,
In our project we are using instantserach.js for search criteria.we have a problem with search i.e, when ever search happens that is not giving correct results for example in our page we are having Like and Unlike actions when ever the authenticated user Like an action the count will be increased and the action is changing as Unlike.we are using algolia with c# to update the index with respective changes.though the Index updated, results are not binding as expected.If we refresh the page then results are coming correctly.As per the documentation of algolia it is showing that each and every time in the search algolia won't hit API,the search will happen from cache.In our case also the thing is same, the results are getting from cache.I tried all the ways to clear cache as following but results are not coming.
var client = algoliasearch('applicationId', 'applicationkey');
var index = client.initIndex('indexname');
index.clearCache();

Please help us to clear the cache at every time search happens.

@vvo
Copy link
Contributor

vvo commented Jun 6, 2016

Hello, sorry for late response, you should be able to clear the instantsearch cache by doing:

// search being your instantsearch instance
search.client.clearCache();

Then when there's a new search on the IS interface, the cache will be cleared.

Let me know if that works.

@ChandanaCH
Copy link
Author

Hello vvo,
Thank you for your reply.It is working fine :)

@shauntrennery
Copy link

How is clearCache called for the new React components?

@vvo
Copy link
Contributor

vvo commented Dec 13, 2016

How is clearCache called for the new React components?

That is not yet feasible, should be feasible this week we are gonna push a new update allowing you to do so

@shauntrennery
Copy link

@vvo I have a list of users. The list is populated using the Algolia searchBox connector. I'm wanting to refresh the index when a user is added or removed. Hope this helps explain my need.

@vvo
Copy link
Contributor

vvo commented Dec 13, 2016

@shauntrennery Most probably what we will expose is this:

import algoliasearch from 'algoliasearch';
var algoliaClient = algoliasearch(...);
const App = () => <InstantSearch algoliaClient={algoliaClient} />;
// ... later on:
// algoliaClient.clearCache();

Would that work for you?

@ishanray
Copy link

ishanray commented Apr 3, 2017

@vvo Any updates on clearing cache for the React Components?

@vvo
Copy link
Contributor

vvo commented Apr 3, 2017

This is actually doable with the syntax above #1050 (comment).

Just submitted a documentation update for the prop.

@tahminabs23
Copy link

hi, how can I do it with angular component?

@Haroenv
Copy link
Contributor

Haroenv commented Jul 13, 2018

@tahminabs23, how are you using InstantSearch and Angular together?

@tahminabs23
Copy link

@Haroenv I am using the angular-instantsearch library. https://github.com/algolia/angular-instantsearch

By the way, I have discovered that instantsearch.js has already implemented refresh() method, but angular-instantsearch library does not add this in their signature. So I have created another issue in angular-instantsearch library.

algolia/angular-instantsearch#185

If they just update the InstantSearchInstance class, it can be easily fixed. We can easily call the refresh() method to refresh our result set.

@Farid02
Copy link

Farid02 commented May 15, 2019

@vvo Vincent Voyer Hello I have a problem of disappearing data in the details of a product during the refresh
I used algolia and nuxtsjs

@trioangle27
Copy link

trioangle27 commented Dec 15, 2022

Hi Bro,
i'm using instant search libary.not javascript
like :

 const search = instantsearch({
    indexName: '********',
    searchClient: algoliasearch('*****', '*********')
});

is possible clear cache

i am search every product

Qty=1000
search.addWidgets([
                 
                        instantsearch.widgets.configure({
                            filters: "price <=" + Qty + " AND price >=" + Qty,
                       
                        }),
                    ]);

search is workig but old search product 2 or 3 product still showing .is possible clear cache

clear-refinement wideget isn't used .

@algolia algolia locked as resolved and limited conversation to collaborators Dec 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants