1
votes

I would like to sort results from a Solr query by their relevance divided by their geo distance from a point. I have tried boosting by 1/distance (using the boost param with edismax) and various variants of this. The problem with this is that depending on the query, the relative weight of the boost varies (e.g. a long query versus a very short one). So I would ideally like to be able to have the distance have the same effect on all queries, as I am building a recommender engine. I can't use MLT as it also does not allow for you to incorporate distance into the MLT request, only doc similarity, to my knowledge. The only way I can think to do this is to embed the entire query into a query function in the sort, e.g.

sort=div(query(deftype=edismax&q=title:java&title:developer), sum(1, geodist(location, x,y)))

The full query is actually much longer, and it seems ridiculous to have it compute the document relevance again in the sort. Is there a better way to do this? Is there a better way to leverage geospatial boosting so that the boost is always proportional to the rest of the query?

1
You've tried boosting based on distance in bf param? (The Solr reference guide provides this example of boosting nearby results: &q.alt=*:*&fq={!geofilt}&sfield=store&pt=45.15,-93.85&d=50&bf=recip(geodist(),2,200,20)&sort=score desc)femtoRgon
Yes, see my post above. That parameter does the same as "boosting by 1/distance" to my understanding. Am I miss-understanding it's usage?Simon
Think I got crossed up there for a moment. So have you used bf, bq or boost params? bf and bq should apply an additive boost (which sounds like what you are describing), and boost should give you a multiplicative boost (which, I believe, is what you want).femtoRgon
@femtoRgon you are right. Post it as an answer and I will mark it as such. Many thanks.Simon
Glad we got there, and sorry for confusing things with the earlier comment.femtoRgon

1 Answers

1
votes

The parameter to use for this sort of boost, is the boost parameter. It works very similarly to the bf parameter, but applies a multiplicative boost; that is, the result of the boost function is multiplied into the score.

The bf and bq parameters add the boost function's result into the score, as if it were another query term, and so more complex queries will generally see the boost function have less relative weight, as you've described.