Ashutosh
Ashutosh

Reputation: 324

Prioritize search results based on certain parameter in AzureSearch.

I have an index on AzureSearch similar to this one:

"fields": [
    {
        "name": "key",
        "type": "Edm.String",
        "filterable": true,
    },
    {
        "name": "title",
        "type": "Edm.String",
        "searchable": true
    },
    {
        "name": "followers",
        "type": "Collection(Edm.String)",
        "filterable": true,
    }
]

Here, title is the title of a Post and its text searchable. followers contains the user ids of users who are following that particular Post.

I am getting current logged in userId from session. Now when a user does some text search, I want to show those Posts on top which current user is following.

Please tell if this is achievable in AzureSearch using ScoringProfiles or anything else?

Upvotes: 0

Views: 83

Answers (1)

Nate Ko
Nate Ko

Reputation: 933

Tag boosting in ScoringProfile does exactly that. All you need to do is to add a scoring profile as below :

{
  "scoringProfiles": [
  {
    "name": "personalized",
    "functions": [
    {
      "type": "tag",
      "boost": 2,
      "fieldName": "followers",
      "tag": { "tagsParameter": "follower" }
    }
    ]
  }
  ]
}

Then, at query time, issue a search query with the scoring profile with the parameters to customize the ranking :

docs?search=some%20post&&scoringProfile=personalized&scoringParameter=follower:user_abc

Hope this helps. You can read more about it here. https://azure.microsoft.com/en-us/blog/personalizing-search-results-announcing-tag-boosting-in-azure-search/

Nate

Upvotes: 1

Related Questions