Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this Azure-Search error about "invalid expression" on $filter

When using both C# .NET code to send a query to Azure Search and when using the "Search Explorer" within the Resource-Manager style Azure Portal, Azure search will succeed when given the query (as input in Search Explorer):

search=foo&facet=category&$filter=category eq 'Teams'

But fail when given:

search=foo&facet=categoryDetails&$filter=categoryDetails eq 'Subcategory'

The error returned is:

{
    "error": {
        "code": "",
        "message": "Invalid expression: The operand for a binary operator
                   'Equal' is not a single value. Binary operators require
                   both operands to be single values.\r\nParameter name:
                   $filter"
    }
}

(Message is a single-line. It's formatted with line breaks here for easier reading.)

I even tried with another facet whose name is also a camelcase term, and the search also hit the same error.

My theory is that camelcase names cause issues with Azure Search. Has anyone else experienced this before? I'll suppose I'll experiment with all lowercase names while waiting for light to be shed on this.

like image 998
starlocke Avatar asked Feb 05 '23 08:02

starlocke


1 Answers

The error had nothing to do with camelcase, but with the fact that those "fields" were of the type DataType.Collection(DataType.String) (an array of strings).

I needed to search using a kind of subquery as shown in Filter and collections in OData

like image 102
starlocke Avatar answered Feb 08 '23 15:02

starlocke