Search code examples
angularazurepostrequestazure-cognitive-search

Search Facets with values using Azure search


I am building a search service in angular2 to call Azure search. I did a post with this data:

{
count:true,
facets:["type", "status"],
queryType:"full",
search:"company && type:value1 || status:value2",
skip:0,
top:10
}

I want to bring all the data that has: type = value1 or status = value2 everything works great but the problem is the result: I am receiving only the results which have the type equals to value1 but not combined with the results that have the status equals to value2.


Solution

  • I'm not sure why the search expression doesn't work as expected, but in situations like this where you're implementing faceted navigation it's usually best to use a filter instead:

    filter: "type eq 'value1' or status eq 'value2'"
    search: "company"
    

    The filter and search parameters are automatically "ANDed" together.

    You can find the reference docs for the OData filter syntax here.