Search code examples
azure-cognitive-searchazure-search-.net-sdk

Azure Search: boost results that contains word


I have an airports database in Azure Search which upon searching I would like to boost results with those airports that contains the word "international" in the airport name.

given 2 results that have the same score, i would like to boost the one that has the word "international" in the airport name using just Azure Search (i.e. if possible, not using any code to manipulate after getting the relevant results).

I tried Term Boosting but it returns me a list of airports that has "international" in them which is not what I want.

I looked at the Scoring Functions but none of them seems to suit my needs

in essence, i do not want to "match" results that contains the word "international" but i want to "boost" results that contains the word "international" after the user keys in the query text


Solution

  • If you want results containing a term to score higher, but you don't want to require matching documents to contain the term, you can use OR as well as AND. For example, if the user typed "Dallas", your query could look like this:

    Dallas OR (Dallas AND airportName:international)
    

    If you further want to control the impact that the term international has on the score, you can use term boosting.

    You might find this article on how Azure Search processes queries to be helpful.