0

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.

Samy Sammour
  • 2,298
  • 2
  • 31
  • 66
  • 1
    Is there any particular reason you're using Lucene syntax for the 'type:value1 || status:value2' part of your query? Usually when implementing faceted navigation, you mark your facetable fields as filterable as well, and then include a filter: "type eq 'value1' or status eq 'value2'" in the request. – Bruce Johnston May 31 '17 at 21:15
  • 1
    Filter syntax reference is here: https://learn.microsoft.com/rest/api/searchservice/odata-expression-syntax-for-azure-search – Bruce Johnston May 31 '17 at 21:15
  • yeah sure, you are right, I just found the exact solution as you mentioned. filter it what I was looking for. if you can write your answer as an answer so I can check it. thank you – Samy Sammour Jun 01 '17 at 08:47

1 Answers1

1

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.

Bruce Johnston
  • 8,344
  • 3
  • 32
  • 42