@@ -305,13 +305,15 @@ async def test_count_unique_metadata_by_filter_async_with_filter(document_store:
305305 async def test_count_unique_metadata_by_filter_async_with_multiple_filters (document_store : AsyncDocumentStore ):
306306 """Test counting unique metadata asynchronously with multiple filters."""
307307 docs = [
308- Document (content = "Doc 1" , meta = {"category" : "A " , "year" : 2023 }),
309- Document (content = "Doc 2" , meta = {"category" : "A " , "year" : 2024 }),
310- Document (content = "Doc 3" , meta = {"category" : "B" , "year" : 2023 }),
311- Document (content = "Doc 4" , meta = {"category" : "B" , "year" : 2024 }),
308+ Document (content = "Doc 1" , meta = {"category" : "B " , "year" : 2023 , "status" : "draft" }),
309+ Document (content = "Doc 2" , meta = {"category" : "B " , "year" : 2023 , "status" : "draft" }),
310+ Document (content = "Doc 3" , meta = {"category" : "B" , "year" : 2023 , "status" : "published" }),
311+ Document (content = "Doc 4" , meta = {"category" : "B" , "year" : 2024 , "status" : "draft" }),
312312 ]
313313 await document_store .write_documents_async (docs )
314314
315+ # The compound filter matches three documents with duplicated values, so the counts only come
316+ # out right when the store both applies the filter and properly counts the values.
315317 counts = await document_store .count_unique_metadata_by_filter_async ( # type:ignore[attr-defined]
316318 filters = {
317319 "operator" : "AND" ,
@@ -320,9 +322,9 @@ async def test_count_unique_metadata_by_filter_async_with_multiple_filters(docum
320322 {"field" : "meta.year" , "operator" : "==" , "value" : 2023 },
321323 ],
322324 },
323- metadata_fields = ["category " , "year" ],
325+ metadata_fields = ["status " , "year" ],
324326 )
325- assert counts == {"category " : 1 , "year" : 1 }
327+ assert counts == {"status " : 2 , "year" : 1 }
326328
327329
328330class DeleteByFilterAsyncTest :
0 commit comments