Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade from LatLonType to LatLonPointSpatialField

I am using Solr 6.5.1

LatLonType is now deprecated (https://lucene.apache.org/solr/guide/6_6/spatial-search.html) and I'm trying to use the LatLonPointSpatialField. I also need it to be multi-valued.

My field is defined as follows:

<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true"/>

I used to boost on my LatLonType field before like that:

boost=recip(geodist(sfield,45.15,-93.12),3 ,10000,3000) (I am using eDisMax).

After I changed the spatial data type, I'm getting this error:

A ValueSource isn't directly available from this field. Instead try a query using the distance as the score. which I don't understand.

The documentation tells nothing about using the geodist function with edismax to use it in boost= parameter. Instead it just suggests to use the function value for sorting: https://lucene.apache.org/solr/guide/6_6/spatial-search.html#SpatialSearch-geodist

However this will not work for me, I don't need to sort on distance, I want the geodist() function to be multipled with score to change the resulting score.

like image 655
Valentin V Avatar asked Nov 08 '22 14:11

Valentin V


1 Answers

The solution that worked for me:

Before (LatLonType):

boost=recip(geodist(coordinates_ll,49.175,-123.003),1,10,1)

After (LatLonPointSpatialField):

boost=recip(geodist(),1,10,1)&pt=49.175,-123.003&sfield=coordinates_ll

like image 142
Valentin V Avatar answered Nov 15 '22 09:11

Valentin V