Algolia and Select2

We were populating Select2 with db values with tag=true so we could dynamically create new options. I am integrating the Select2 with algolia now. Is it possible to add a new option dynamically in the Select2 (and when added to db would get pushed to algolia via queue)?

What you will want to do is the following process:

  1. in the place where you update data to Algolia, add a hook
  2. after you send an update to Algolia, listen to waitTask to see that update propagated
  3. somehow notify your frontend (SSE or web sockets)
  4. listen to this hook frontend
  5. update the data and redo the query based on that event

I hope that helps!

Hi haroen, Thanks for the prompt reply. Adding a new data items to the index is not the issue. The issue is when select2 is populating data from algolia, it does not allow tag=true. The point is how to make it allow user enter new data in select2

I’m not sure which solution for synchronising with Select2 you chose, could you share the code you’re currently using?