[Problem]Concurrent requests to update a like counter

I am implementing a like/unlike system. Because of the algolia search, we put our like counter on algolia db, and because of the async feature that algolia is employing, we cannot guarantee the right order of incrementing likes counter. Here we don’t find any increment operator, so we have to first find the object, then use the object’s data to do the partial update, which leaves us a lot of disorder here. Simply the next data is based on random data, we are stuck at here, please help us!


Hi @junchenp1018,

I understand that you are keeping a counter on your Algolia index and having a hard time deciding when to update that counter. Did I understand correctly?

Algolia is not a database, but an index of your data which should only be used in the search. You should keep the counter in your own application database and then sync that database with Algolia for searching.

You may not need to keep the counter in your Algolia index at all, unless you are using it as a ranking factor in your search, as it’s best to only keep the attributes in your index that you need for ranking, sorting or displaying results.

Once you have search results, then you could pull the counter information from your own database for that object returned in the search.

Let me know if I’ve misunderstood your question, or if this leads to other questions.