I would like to implement a search logic like this "Give me all articles from the index that match my term and prefer articles from a certain category".
In elastic search it is possible to implement this with "should" Boolean queries: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
should The clause (query) should appear in the matching document.
But I am not sure how to implement this in Azure Cognitive Search. One option would be to make a search for all articles that are not in the category and then all all that are in the category and make some kind of global order based on the scoring.
Is there a built-in functionality?
You should be able to achieve the desired behavior by using the search.ismatchscoring which allows writing full-text search in filter expressions.
This filter expression will ensure that skateboards
is in the Title
and search for sports
in the Category
to contribute to scoring but it will still return documents in other categories due to the or
statement:
search.ismatchscoring('skateboards', 'Title') and (search.ismatchscoring('sports', 'Category') or search.ismatchscoring('*'))