lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Lucene 5.3.0 GeoPointDistanceQuery
Date Mon, 24 Aug 2015 22:40:58 GMT

you can use the lucene-expressions module and use the distance function there as part of the
score. In general, just sorting by distance brings bad user experience, because you would
ignore the score completely. So you should just "tune" the score by taking the distance into
account, e.g. newscore = score / distance. And you can do this with expressions, the formula
can be given as Javascript function, see
(haversin function is giving distance on earth).

If you want to hardcode the stuff in plain java, you can also use CustomScoreQuery from the
lucene-queries module:
You can use this query and change the score of the inner query ("subquery") and provide a
CustomScoreProvider or FunctionQuery. 

For both solutions you need latitude and longitude as a DocValues field.


Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen

> -----Original Message-----
> From: Pablo Mincz []
> Sent: Monday, August 24, 2015 10:27 PM
> To:
> Subject: Lucene 5.3.0 GeoPointDistanceQuery
> Hi,
> I'm using GeoPointDistanceQuery to filter the results near by a certain
> coordinate, but now I want to sort them by distance to that coordinate.
> I did not find anything in the github repository on how to do this.
> Someone know how to do this?
> Thanks for the help!
> Regards,
> Pablo.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message