#community-help

Correct Formatting for Execute Batch Delete Commands

TLDR Nikunj encountered an error while executing a multiple delete command. Kishore Nallan helped correct the syntax and directed to relevant documentation.

Powered by Struct AI
5
8mo
Solved
Join the chat
Feb 01, 2023 (8 months ago)
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
09:09 AM
hello,
doing multiple delete like this but getting this give error
code
await client.collections(collectionName).documents().delete({ 'filter_by=id': ids })

error
Request failed with HTTP code 400 | Server said: Parameter `filter_by` must be provided.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:10 AM
Filter syntax is wrong. Please refer to the search filtering docs to see example
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
09:18 AM
filter_by=id: [id1, id2, id3]

it is showing a similar syntax
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:03 AM
It must be:

await client.collections(collectionName).documents().delete({ 'filter_by': 'id: [id1, id2]' })
10:05
Kishore Nallan
10:05 AM
The delete by query documentation also shows this sample query: https://typesense.org/docs/0.24.0/api/documents.html#delete-by-query