#community-help

Deleting All Documents in Typesense Collection

TLDR Vikas wanted to delete all documents in a typesense collection. Kishore Nallan suggested using a range filter on a numerical field to match and delete the entire dataset.

Powered by Struct AI
3
30mo
Solved
Join the chat
Jun 01, 2021 (30 months ago)
Vikas
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Vikas
08:49 AM
Hello, started using typesense for an internal service and have been loving it. API's are great and easy to use.
I have hit one hurdle where I want to delete all documents for a collection. I know we can delete the collection itself but was checking if there is a way to delete all documents.
I have seen delete by filter_by api as well, but I cannot run something like name "not equal"(name: !="blah") to match all documents and delete them. Any pointers?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:54 AM
Vikas We don't have a truncate collection end-point. However, you can achieve that with delete by filter API by doing a range filter on a numerical field with a value that matches the whole dataset. E.g. points: >= 0
Vikas
Photo of md5-d7f4aa44e3d4866e8b7a38eceb9af762
Vikas
11:00 AM
thanks Kishore Nallan I had that as a backup plan.