Deleting Records Not in List with Python and Filters
TLDR Mojan needed help deleting records not in a list using filters. Gustavo suggested using filter_by
and Mojan successfully implemented the solution using Python.
1
Jun 20, 2023 (3 months ago)
Mojan
10:47 PMGustavo
10:53 PMfilter_by=id:!=[id1,id2,id3]
does what you need, but try it with caution, I'm not 100% sureMojan
11:17 PMdoc_ids
. Do you know how I would place the list name in there ? Because, I can't certainly put that inside quotes.Do you know how I can do that without quotes ?
Gustavo
11:31 PMMojan
11:36 PM {'filter_by': f"doc_id: != {doc_ids}"}
and it worked !
Thank you for your help :)
1
Jun 21, 2023 (3 months ago)
Ed
09:02 AMEd
09:02 AMMojan
09:12 PMclient.collections[table_name].documents.delete({'filter_by': f"{col_name}: != {id_list}"})
table_name
is the name of the db table which is the same as index name here, column_name
is the name of the field , which in this case is doc_id
and id_list
is the list which is being fed to the function .Typesense
Indexed 2779 threads (79% resolved)
Similar Threads
Typesense Cloud Issue: Unable to Delete Documents by ID
Ellen had trouble using Typesense Cloud's `filter_by` option to delete documents by id. Jason solved this by suggesting to remove double-quotes around IDs in `filter_by` clause.
Resolving Document Export & Batch Deletion Issues
Dui had trouble exporting a document and wanted batch deletion assistance. Kishore Nallan fixed the export issue, upgraded their cluster manually and suggested using `delete by query`.
Batch Deletion Error in Typesense Using Array of IDs
sonu was confused about batch deleting with an array of ids. Kishore Nallan clarified that they'd need to explicitly add ids as a field because they're not indexed. Future improvements planned.
Deleting All Documents with Filter_by
Mischa wants to delete all documents using `id:*` filter but encounters issues. Jason suggests a workaround and advises creating a GitHub issue for the desired feature.
Correct Formatting for Execute Batch Delete Commands
Nikunj encountered an error while executing a multiple delete command. Kishore Nallan helped correct the syntax and directed to relevant documentation.