You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sp <sp...@4info.com> on 2017/12/04 05:47:13 UTC
Ring geospatial query
Hello,
Does lucene java api have a way to do a ring geospatial query around a
LatLonPoint and return the results sorted by distance? By ring, I mean
points which lie beyond an inner radius and within an outer radius
Any suggestions are greatly appreciated.
Thanks
--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Ring geospatial query
Posted by sp <sp...@4info.com>.
Thanks Adrien.
My documents do have a single geo-point, and your suggestion worked. This is
my final code.
Query latlonQuery = LatLonPoint.newDistanceQuery("loc", lat. lon,
outerRadiusMeters);
Query innerRadiusQuery = LatLonPoint.newDistanceQuery("loc", lat, lon,
innerRadiusMeters);
latlonQuery = new BooleanQuery.Builder()
.add(latlonQuery, BooleanClause.Occur.MUST)
.add(innerRadiusQuery, BooleanClause.Occur.MUST_NOT)
.build();
Thanks again.
--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Ring geospatial query
Posted by Adrien Grand <jp...@gmail.com>.
We don't have such a query, but there are workarounds.
- If you need this feature for pagination, you should instead use
IndexSearcher.searchAfter with a LatLonPointSortField.
- If your documents have a single geo-point, you could build a boolean
query with a distance query or the outer radius a a FILTER clause and a
distance query of the inner radius as a MUST_NOT clause.
Le lun. 4 déc. 2017 à 09:16, sp <sp...@4info.com> a écrit :
> Hello,
>
> Does lucene java api have a way to do a ring geospatial query around a
> LatLonPoint and return the results sorted by distance? By ring, I mean
> points which lie beyond an inner radius and within an outer radius
>
> Any suggestions are greatly appreciated.
> Thanks
>
>
>
> --
> Sent from:
> http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>