How to increase Solr relevance by contacting a surveyor ()

So, I have implemented and successfully used Solr 4. I have to say that Solr 4 is awesome! In any case, I successfully sorted by distance and used a geofilter to limit the results to a specific area. What I would like to do now is to increase my relevance score with respect to distance. This page talks about it, but does not say how to do it (http://wiki.apache.org/solr/SpatialSearch)

I tried the following, but this gives me an error:

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

The error I am getting is:

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

Any help would be greatly appreciated. Thanks!

+4
source share
3 answers

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

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

If you are only interested in increasing the return distance, you can use a wildcard query:

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

... or use the function parser:

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

You also need to specify lat / long values ​​and a spatial field for the request, either as arguments to the surveyor function:

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

... or taken into account as query string parameters:

 q={!boost b=recip(geodist(),1,1000,1000)}foo:bar&sfield=myGeoField&pt=50.1,-0.86 
+11
source

Just add that I have better results with ...

 {!boost b=recip(geodist(),1,100,10)} 

I do not know what causes this, but I want Sol to give a little more information about the parameters for the recipe and raise it. There is no current documentation .

0
source

As a side note, this is the increase in distance used at my place of work. It differs from the version on the Solr documentation site. This acceleration function will process the distance the same way for several kilograms before acceleration begins. This is useful in some situations where you do not need changes in relevance for small differences in distances.

You can change the constant 25 to any number of kilometers in which you want the gain to be the same.

You can define the distance increase as such:

 div(1.0, min(1000, max(25, geodist()))) 

distance increase graph

0
source

Source: https://habr.com/ru/post/1335689/


All Articles