Home > Software design >  Is it possible to query an Azure Search Index for a specified field of type Collection being not nul
Is it possible to query an Azure Search Index for a specified field of type Collection being not nul

Time:11-15

I need to query a large Azure Index to find all records where a particular field (being simply a collection or array of strings) is null but I am having trouble trying to use Odata expressions to identify them since apparently this type of data cannot quantify for use in a filter as such:

{
   "search": "*",
   "queryType": "full",
   "select": "Email",
   "count": true,
   "filter": "Skills eq null"
}

Attempting is this manner will throw the following error:

The operand for a binary operator 'NotEqual' is not a single value. Binary operators require both operands to be single values.\r\nParameter name: $filter

So how might I achieve a listing of these records where the corresponding Collection(Edm.String) is an empty array?


      UPDATED

Thanks guys. Per the recommended solution, the following returns only those collections having records.

{
    "searchMode": "any",
    "queryType": "full",
    "select": "QualifiedFor",
    "count": true,
    "filter": "Skills/any()"
}  

CodePudding user response:

$filter uses OData:

The any operator applies a Boolean expression to each member of a collection and returns true if the expression is true for any member of the collection, otherwise it returns false. The any operator without an argument returns true if the collection is not empty.

Source: http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc371341806

as @Guarav Matri said, just use $filter=Skills/any()

  • Related