@@ -342,102 +342,6 @@ def test_sentence_window_retriever(self, document_store: PineconeDocumentStore):
342342
343343 assert len (result ["context_windows" ]) == 1
344344
345- def test_delete_by_filter (self , document_store : PineconeDocumentStore ):
346- docs = [
347- Document (content = "Doc 1" , meta = {"category" : "A" }),
348- Document (content = "Doc 2" , meta = {"category" : "B" }),
349- Document (content = "Doc 3" , meta = {"category" : "A" }),
350- ]
351- document_store .write_documents (docs )
352-
353- # delete documents with category="A"
354- deleted_count = document_store .delete_by_filter (
355- filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }
356- )
357- assert deleted_count == 2
358- assert document_store .count_documents () == 1
359-
360- # verify only category B remains
361- remaining_docs = document_store .filter_documents ()
362- assert len (remaining_docs ) == 1
363- assert remaining_docs [0 ].meta ["category" ] == "B"
364-
365- def test_delete_by_filter_no_matches (self , document_store : PineconeDocumentStore ):
366- docs = [
367- Document (content = "Doc 1" , meta = {"category" : "A" }),
368- Document (content = "Doc 2" , meta = {"category" : "B" }),
369- ]
370- document_store .write_documents (docs )
371-
372- # try to delete documents with category="C" (no matches)
373- deleted_count = document_store .delete_by_filter (
374- filters = {"field" : "meta.category" , "operator" : "==" , "value" : "C" }
375- )
376- assert deleted_count == 0
377- assert document_store .count_documents () == 2
378-
379- def test_update_by_filter (self , document_store : PineconeDocumentStore ):
380- docs = [
381- Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "draft" }),
382- Document (content = "Doc 2" , meta = {"category" : "B" , "status" : "draft" }),
383- Document (content = "Doc 3" , meta = {"category" : "A" , "status" : "draft" }),
384- ]
385- document_store .write_documents (docs )
386-
387- # update status for category="A" documents
388- updated_count = document_store .update_by_filter (
389- filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }, meta = {"status" : "published" }
390- )
391- assert updated_count == 2
392-
393- published_docs = document_store .filter_documents (
394- filters = {"field" : "meta.status" , "operator" : "==" , "value" : "published" }
395- )
396- assert len (published_docs ) == 2
397- for doc in published_docs :
398- assert doc .meta ["category" ] == "A"
399- assert doc .meta ["status" ] == "published"
400-
401- def test_update_by_filter_multiple_fields (self , document_store : PineconeDocumentStore ):
402- docs = [
403- Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "draft" , "priority" : "low" }),
404- Document (content = "Doc 2" , meta = {"category" : "B" , "status" : "draft" , "priority" : "low" }),
405- Document (content = "Doc 3" , meta = {"category" : "A" , "status" : "draft" , "priority" : "low" }),
406- ]
407- document_store .write_documents (docs )
408- assert document_store .count_documents () == 3
409-
410- # Update multiple fields for category="A" documents
411- updated_count = document_store .update_by_filter (
412- filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" },
413- meta = {"status" : "published" , "priority" : "high" },
414- )
415- assert updated_count == 2
416-
417- # Verify the updates
418- published_docs = document_store .filter_documents (
419- filters = {"field" : "meta.status" , "operator" : "==" , "value" : "published" }
420- )
421- assert len (published_docs ) == 2
422- for doc in published_docs :
423- assert doc .meta ["category" ] == "A"
424- assert doc .meta ["status" ] == "published"
425- assert doc .meta ["priority" ] == "high"
426-
427- def test_update_by_filter_no_matches (self , document_store : PineconeDocumentStore ):
428- docs = [
429- Document (content = "Doc 1" , meta = {"category" : "A" }),
430- Document (content = "Doc 2" , meta = {"category" : "B" }),
431- ]
432- document_store .write_documents (docs )
433- assert document_store .count_documents () == 2
434-
435- # Try to update documents with category="C" (no matches)
436- updated_count = document_store .update_by_filter (
437- filters = {"field" : "meta.category" , "operator" : "==" , "value" : "C" }, meta = {"status" : "published" }
438- )
439- assert updated_count == 0
440- assert document_store .count_documents () == 2
441345
442346 def test_count_documents_by_filter (self , document_store : PineconeDocumentStore ):
443347 docs = [
0 commit comments