#community-help

Deleting Documents from Typesense Cloud and Version Upgrade

TLDR Masahiro asked how to remove documents from Typesense. Kishore Nallan clarified it varies by version and suggested upgrading from 0.20 to 0.22. Masahiro agreed to test this.

Powered by Struct AI
9
23mo
Solved
Join the chat
Dec 15, 2021 (23 months ago)
Masahiro
Photo of md5-366dff6b5f9b1a7d0f404fdc3261e573
Masahiro
06:58 AM
Hi 👋
I have a question about how to remove documents from Typesense (Typesense Cloud).
For example, if I want to delete 100 documents from a collection, how do I write the query? I used page and per_page, but I could not limit the number of documents to be deleted.
Regards
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:00 AM
What version of Typesense are you on?
07:01
Kishore Nallan
07:01 AM
In 0.22 you can use delete by query which supports deleting by using list of IDs as filter. On 0.21 we don't support deleting my IDs.
Masahiro
Photo of md5-366dff6b5f9b1a7d0f404fdc3261e573
Masahiro
07:07 AM
Thank you for your quick reply!
Mine is 0.20.0.
Is there any way to write the query as follows?
client
.collections("reactions")
.documents()
.delete({
limit: 100,
filter_by: updatedAt:>${unixTimestamp}&&reactionType:=2,
});
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:08 AM
No, the only way on 0.20 to do this is to issue a search query, and then fetch the document IDs, and issue individual delete requests.
07:08
Kishore Nallan
07:08 AM
You should consider upgrading also 🙂
Masahiro
Photo of md5-366dff6b5f9b1a7d0f404fdc3261e573
Masahiro
07:09 AM
OK!
Could you upgrade one of our clusters to latest version?
svfb42xjgnecu83hp-1.a1.typesense.net
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:13 AM
Is this a dev cluster? Or please test the changes first since it's a significant bump. Also I am not sure if we can jump 2 versions directly. We will have to do 0.20 -> 0.21 -> 0.22.

An alternative approach will be to launch a new 0.22 cluster, re-index your data, test and switch your app and shut the old clusters after that.
Masahiro
Photo of md5-366dff6b5f9b1a7d0f404fdc3261e573
Masahiro
07:30 AM
OK! I will test!