My response to a direct email (copying here with permission):

It's possible; you'll certainly have to write some code here to make this
work, including some new Solr plugin; perhaps ValueSourceParser that can
compute a more accurate overlap.  Such a thing would have to get the
Spatial4J Shape from the RptWithGeometrySpatialField (see getValues).  Then
some casting to unwrap it to get to a JTS Geometry.  All this is going to
be slow, so I propose you use Solr query re-ranking to only do this on the
top results that are based on the bounding-box overlap ratio as an
approximation.

https://lucene.apache.org/solr/guide/8_3/query-re-ranking.html

---------- Forwarded message ---------
From: Marc
Date: Tue, Jan 7, 2020 at 6:14 AM
Subject: Solr spatial search - overlapRatio of polygons
To: David Smiley <dsmi...@apache.org>



Dear Mr Smiley,

I have a tricky question concerning the spatial search features of
Solr and therefore I am directly contacting you, as a specialist.

Currently I am developing a new catalogue for our map collection with
Solr. I would like to sort the search results by the overlap ratio of
the search rectangle and the polygon of the map corners. Solr provides
such a feature for comparing and sorting bounding boxes only.
But it should be possible to compare polygons with the help of JTS
functions
(locationtech.github.io/jts/javadoc/org/locationtech/jts/geom/Geometry.html).

With intersection() you can compute the geometry of the overlapping
part. Afterwards you may calculate the size of it with getArea() and
compare it with the size of the search rectangle.
Is there a way to use such JTS functions in a Solr query? Or do you
know another option to sort by the overlap ratio of polygons?

Reply via email to