Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top