I'm trying to delete all records in my index that ...
# community-help
m
I'm trying to delete all records in my index that don't exist in a particular list. Not sure how I would put that condition in there
g
I believe
filter_by=id:!=[id1,id2,id3]
does what you need, but try it with caution, I'm not 100% sure
m
So the list is made dynamically and has a name , let's say
doc_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 ?
g
I guess it depends on the language
m
Python. I tried :
Copy code
{'filter_by': f"doc_id: != {doc_ids}"}
and it worked ! Thank you for your help :)
🙌 1
e
do you midn sharing the whole query?
@Mojan
m
I don't have a whole query so to speak. I have a function, which deletes the records. You feed it a list of ids and it deletes all the records in the index that don't exist in that list :
Copy code
client.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 .