Hello, I’m having trouble understanding how to structure the metadataFilter
for filters of “list” types.
My documents have an indexed list (array) of integers (category IDs). I want to filter to documents that have a given category ID. For example, let’s say I have a document with doc.categories
of [1,2,3]
.
I have tried 1 IN doc.categories
and (1) IN doc.categories
, but both are invalid queries. doc.categories = 1
returns zero results.
How would I write a filter to include that document?
Hey @apologist_project,
We have not enabled metadata filtering for list types at this point.
Can you please share more about your specific requirements? Are you always trying to filter by an exact match (“X in list”) or would your application need broader functionality like list intersect operations)?
@ofermend It would be an intersect ideally. Each doc in our corpus has a list of categories. Then a user will select any number of categories to filter the docs down to. For example:
doc 1: [category A, category B, category C]
doc 2: [category B, category C]
doc 3 [category A]
If user asks for information about category B or category C, then doc 1 and doc 2 should return (but not doc 3). Best case scenario would be: [category B, category C] IN doc.categories
or similar, which would return any docs with EITHER category B or category C.
However, I could make it work if at least I could match on single category as well. e.g., 'category B' IN doc.categories OR 'category C' IN doc.categories
; that might be more flexible anyway.
Are there currently any workarounds for this use case?
Thanks. This is helpful to know.
For workaround: if you have a small-ish number of categories, you can always create a filter attribute per category but this won’t scale of course.
Thanks for the assistance @ofermend. In the short term I can get by with just referencing the individual document IDs rather than categories for my immediate use case.