Forum Discussion
at_cb
Sep 04, 2023Copper Contributor
Filter on array length in Azure Cognitive Search
How can I fetch index records by filtering on array length?
For ex. I have an array property "Contracts". I want to fetch records where Contracts is a blank array.
All I could find in documentation is "any" (Contracts/any) and "all" (Contracts/all) but I want to use something like $filter=Contracts/count eq 0. Is there a way to filter on length of array?
1 Reply
Azure Cognitive Search does not support filtering directly on array length (e.g., Contracts/count eq 0). The OData filter syntax only allows any and all for collections. To find records where an array is empty, you must use a workaround such as checking for null or using not Contracts/any().