how to make the score to be a percentage?
wiredots01 opened this issue · comments
{ $text: { $search: searchValue } },
{
fields: {
score: { $meta: 'textScore' }
},
sort: {
score: { $meta: 'textScore' }
}
}
I'm not sure that that is even possible. The documentation for the $text
operator doesn't mention being able to control what value is returned for textScore
. If this is something you really need you may want to ask on the mongodb forums/mailing lists.
Or if it's something you really really need, you could make try generating percentages based on the textScore
s relative values. For example, taken from the above link:
{ "_id" : 2, "subject" : "Coffee Shopping", "author" : "efg", "views" : 5 }
{ "_id" : 7, "subject" : "coffee and cream", "author" : "efg", "views" : 10 }
{ "_id" : 1, "subject" : "coffee", "author" : "xyz", "views" : 50 }
You could transform the last result "coffee" to have 100%, with the second row being 20% and the last row being 10%. I'm not sure that that really makes sense though.
I'll close this issue but feel free to reopen it if you have further questions :)