如何查询Azure搜索索引中Collection类型字段为null或空数组的记录
Azure 索引Collection类型字段OData筛选解决方案
Collection(Edm.String)是多值类型,OData二元运算符要求操作数为单值,因此直接使用Skills eq null的写法会触发如下错误:
The operand for a binary operator 'NotEqual' is not a single value. Binary operators require both operands to be single values. Parameter name: $filter
两种常见筛选场景的正确写法如下:
- 筛选集合字段存在至少一个元素的记录:使用无参数的
any()运算符,判断集合至少包含一个元素,请求示例如下:
{ "searchMode": "any", "queryType": "full", "select": "QualifiedFor", "count": true, "filter": "Skills/any()" }
- 筛选集合字段为空数组或为null的记录:对
any()的结果取反即可,请求示例如下:
{ "search": "*", "queryType": "full", "select": "Email", "count": true, "filter": "not Skills/any()" }
内容的提问来源于stack exchange,提问作者Mark
相关产品推荐
相关产品推荐

