Question

I am trying to implement a search engine for a new app.

The app allows people to rate items (+1 or -1) - Giving the items a +ve or -ve score.

When people search for items, I'd like to take into account their rating and to order the results accordingly. If the item is a match, it should show up. But if it's a match with a high score it should be boosted up the results a bit.

A really good match should win over a fairly good match with a high score, so it needs to be weighted along with the rest of it (i.e. I boosted my titles a bit).

Not stuck on Solr by any means, only just started playing today.

Was it helpful?

Solution

With Solr, you can maintain a field with the document which holds the difference.
The difference can be between the total +1ve's and the -1ve's.

Solr allows you to boost on field values using function queries.
So you can query with the boost on the difference field, with documents with better difference scoring over others.

From indexing front, as this difference would change quite often, the respective document needs to be updated everytime. Solr does not allow the updation of the single field, so you need to handle the incremental updates of the difference field.

If that would be a concern to you, can try using ExternalFileField.
This allows mapping of certain fields of documents such as ranking, popularity external to the index in a separate file.
The file can be updated and index committed to reflect the changes.
The field can also be used with function queries to boost the results as needed, however have lot of limitations.

OTHER TIPS

You can order your results by a field that stores the ranking.

sqs.filter(content='blah').order_by('rating')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top