开发者

Presenting SOLR results merged with individual user data

I'm looking for a strategy to present a individual user's rating on a solr document. ie. Users get to put give a rating 1-5 on a document and I want to present that back to them as they search.

I can think of two general approaches.

  1. Store the ratings in my RDBMS and query it after getting solr results and merge the data in business logic.

  2. Somehow also store this rating info in solr so it comes back with the data for a given user. All I can think of is attributes names with the userid and a value of rating.

Assuming a large user base, I worry approach 2 could get ou开发者_JS百科t of hand. How "wide" can you go with a solr document? Can you put tens of thousands of attributes on a document? Would the performance impact still leave approach 2 better than a second hit on a sql db(approach 1)?

Are there other approaches I'm not thinking of?


I've used approach number 1. Since the number of ratings is low (probably less than 1000) per user, I just cache all their ratings upon login and store in memory. Then, when showing the SOLR results, it is very quick to just apply the ratings where needed.

This saves you from having a database call for each result and doesn't bog down the server too much. Plus, when a user updates their ratings, you just update the DB and invalidate the cache. You don't have to make an UPDATE call to a SOLR document.


A third option might be to add an additional Solr index that contains just the document id, user id and the score aattributed to that document by the user. It would then be very simple and rapid to query the score by document & user.


I would go with number 2, and only periodically update the rating. That way you can blend in the rating into the relevancy score calculated by Solr.

I think it depends on if you are like Digg/Reddit, where the up/down voting drastically impacts what is shown, or if it's just another factor in scoring, like how new the document is. If it's just another factor, then update your document once a day, a week or once a month in the quiet hours....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜