I am experiencing issues with array (think permissions-style) filtering in my hybrid search. I suspect the problem lies in my data type definition, tokenization settings, or the filter query itself. Here’s my scenario:
In my collection, I have a property that lists the roles with access to each data row.
Property: allowrole = [“Admin”, “User Admin”, “Reader”, “Editor”]
Property(name=“allowrole”, data_type=DataType.TEXT_ARRAY, skip_vectorization=True, vectorize_property_name=False, tokenization=Tokenization.FIELD),
I have defined this property as DataType.TEXT_ARRAY
and tried different tokenization settings (FIELD, LOWERCASE, none, etc).
Goal: Filter results where at least one role in the query array exactly matches one of the roles in allowrole
.
Example Data:
{name: "TestA", allowrole: ["Reader"]}
{name: "TestB", allowrole: ["Admin"]}
{name: "TestC", allowrole: ["User Admin"]}
{name: "TestD", allowrole: ["Admin", "Editor"]}
Example Query Array for input
["Admin", "Reader"]
Issue: When using ContainsAny
filtering, a query with ["Admin", "Reader"]
returns all records, including partial matches like “Admin” in “User Admin”. The expected result should be Data 1, 2, and 4 only.
Using an OR filter on allowrole
also results in partial matches, which is not desired.
How can I achieve exact matching for array filtering like this?