okgrow / meteor-text-search-demo

A demo app showing how to do full text search in Meteor 1.2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 textScores 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 :)