Hi,

our strategy is to have a separate center coordinate field that we use for sorting. This has the additional benefit that it's possible to have the indexed center point differ from the polygon's centroid, which can be useful e.g. with cities, where the city center can be quite a bit offset from the centroid.

--Ere

Grondin Luc kirjoitti 13.9.2017 klo 0.07:
Hello,

I am having difficulties with sorting by distance resources indexed with WKT 
geolocation data. I have tried different field configurations and query 
parameters and I did not get working results.

I am using SOLR 6.6 and JTS-core 1.14. My test sample includes resources with point coordinates 
plus one associated with a polygon. I tried using both fieldtypes 
"solr.SpatialRecursivePrefixTreeFieldType" and 
"solr.RptWithGeometrySpatialField". In both cases, I get good results if I do not care 
about sorting. The problem arises when I include sorting.

With SpatialRecursivePrefixTreeFieldType:

The best request I used, based on the documentation I could find, was:
select?fl=*,score&q={!geofilt%20sfield=PositionGeo%20pt=45.52,-73.53%20d=10%20score=distance}&sort=score%20asc

The distance appears to be correctly evaluated for resources indexed with point 
coordinates. However, it is wrong for the resource with a polygon

<result name="response" numFound="5" start="0" maxScore="20015.115">
   <doc><float name="score">2.3913236</float></doc>
   <doc><float name="score">4.3242383</float></doc>
   <doc><float name="score">4.671504</float></doc>
   <doc><float name="score">4.806902</float></doc>
   <doc><float name="score">20015.115</float></doc>
</result>

(Please note that I have verified the polygon externally and it is correct)

With solr.RptWithGeometrySpatialField:

I get an exception triggered by the presence of « score=distance » in the 
request « 
q={!geofilt%20sfield=PositionGeo%20pt=45.52,-73.53%20d=10%20score=distance} »

java.lang.UnsupportedOperationException
                 at 
org.apache.lucene.spatial.composite.CompositeSpatialStrategy.makeDistanceValueSource(CompositeSpatialStrategy.java:92)
                 at 
org.apache.solr.schema.AbstractSpatialFieldType.getValueSourceFromSpatialArgs(AbstractSpatialFieldType.java:412)
                 at 
org.apache.solr.schema.AbstractSpatialFieldType.getQueryFromSpatialArgs(AbstractSpatialFieldType.java:359)
                 at 
org.apache.solr.schema.AbstractSpatialFieldType.createSpatialQuery(AbstractSpatialFieldType.java:308)
                 at 
org.apache.solr.search.SpatialFilterQParser.parse(SpatialFilterQParser.java:80)

 From there, I am rather stuck with no ideas on how to resolve these problems. 
So advises in that regards would be much appreciated. I can provide more 
details if necessary.

Thank you in advance,


  ---
   Luc Grondin
   Analyste en gestion de l'information numérique
   Centre d'expertise numérique pour la recherche - Université de Montréal
   téléphone: 514-343-6111 p. 3988  --  
luc.gron...@umontreal.ca<mailto:luc.gron...@umontreal.ca>



--
Ere Maijala
Kansalliskirjasto / The National Library of Finland

Reply via email to