I am using MongoDB atlas search. How can I assign a score for one field based on the value in another field? In the below example I have an array of objects called tags with two properties - name and tag_category.
The data structure is like this in MongoDB.
{
“_id”:ObjectId(“6094e1dd0ac22244fd1cd5c3”),
"tags":
[
{
"name":"India",
"tag_id":"6094e1bb72bff620f43b0f77",
"tag_category":"region"
},
{
"name":"something else",
"tagid":"aaaae1bb72bff620f43b0faa",
"tag_category":"general"
}
]
}
Note that I am querying for tags.name here.
I want to have a score of 15 for tags.name when tags.tag_category is “region” and score of 5 when tags.tag_category is “general” when query matches search result.
In the above example, when my query matches “India”, I want the result to have the score of 15 as the tag category is region. If it matches “something”, score should be 5 as the tag category is general
How can I achieve this? Any help is appreciated