Reputation: 2590
Now I have a solr collection: question
question has some field:
id
answer_count
created_at
updated_at
now I have the sort rule:
score = answer_count * 100 - (the hours now to created_at) * 5
then I need to sort by the score desc.
how can i do that because of the score is realtime?
Upvotes: 0
Views: 69
Reputation: 3861
The key for this are function queries. Assumed you use EDisMaxQP, you can specify a boost function (bf
) with this value:
sub(product(answer_count,100),product(div(ms(NOW,created_at),3600000),5))
However, a function query would influence scoring, but it rather looks like you don’t want any scoring at all and instead a fixed sort order, so I guess it’s rather a case of using this as value of sort
:
sub(product(answer_count,100),product(div(ms(NOW,created_at),3600000),5)) desc
Of course, boosting newer documents is in the FAQ and you could have found out this for yourself.
Upvotes: 1