Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to boost Solr relevancy score by inverse of geodist()

So I've implemented and successfully used Solr 4. I've got to say that Solr 4 is awesome! Anyway I successfully sorted by distance and used a geofilter to limit the results to a certain area. What I would like to do now is boost the relevancy score by the inverse of the distance. This page talks about it but doesn't say how to do it (http://wiki.apache.org/solr/SpatialSearch)

I've tried the following but it gives me an error:

http://localhost:8983/solr/select/?q={!boost b=recip(geodist(), 1, 1000, 1000)}...

The error I get is:

org.apache.lucene.queryParser.ParseException: Expected identifier at pos 27 str='{!boost b=recip(geodist(), 1, 10 in ...

Any help would be appreciated. Thanks!

like image 774
Chris L. Avatar asked Dec 21 '22 19:12

Chris L.


1 Answers

You still need to specify the main part of your query after the boost function:

q={!boost b=recip(geodist(),1,1000,1000)}foo:bar&...

If you're only interested in boosting by the inverse of the distance you can use a wildcard query:

q={!boost b=recip(geodist(),1,1000,1000)}*&...

...or use the function query parser:

q={!func}recip(geodist(),1,1000,1000)&...

You also need to specify the lat/long values and spatial field to query against either as arguments of the geodist function:

q={!boost b=recip(geodist(50.1, -0.86, myGeoField),1,1000,1000)}foo:bar&...

...or factored out as query string parameters:

q={!boost b=recip(geodist(),1,1000,1000)}foo:bar&sfield=myGeoField&pt=50.1,-0.86
like image 117
Thibaut Avatar answered Jan 11 '23 09:01

Thibaut