jaeyson / ex_typesense

Typesense client for Elixir with support for importing your Ecto schemas.
https://hexdocs.pm/ex_typesense
MIT License
25 stars 7 forks source link

Clear all documents without dropping schema #33

Closed jaeyson closed 6 days ago

jaeyson commented 2 weeks ago

Implements #28

Problem

Based on the Typesense issue, it seems that the only way to delete all documents in a collection is to simply delete the collection and recreate it.

Workaround

Implement a logic, preferably a catch-all filter if no query filter_by is passed in function.

So, 2 possible ways to use the function:

To delete multiple documents by ID, you can use filter_by=id: [id1, id2, id3].

To delete all documents in a collection, you can use a filter that matches all documents in your collection. For eg, if you have an int32 field called popularity in your documents, you can use filter_by=popularity:>0 to delete all documents. Or if you have a bool field called in_stock in your documents, you can use filter_by=in_stock:[true,false] to delete all documents.