I don't have any experience with lucene but I do have experience with querying geographic coordinates based on distance. If you were using mysql or postgis you could store the coordinates as a point data type and use a length or distance function to limit the result. Not sure how lucene works but you will probably need to use math to calculate the distance. If your coordinates are in degrees the math will be more complex since a distance of 1 degree is different depending on the direction and where it is. For example, 1 degree north is always the same but one degree west is much farther at the equator than it is nearer the poles. Converting the points to a projection that uses meters instead of degrees would probably make the math easier.
I quickly glanced through the Zend_Search_Lucene docs on querying and didn't see any math functions so you may need to do a search that brings back everything regardless of distance and then do the math separately to filter out everything outside your distance range. I'm sure you have your reasons for using lucene over sql but this could be a reason to use sql instead. You can review the mysql spatial extensions here: http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html Could you store ids and coordinates in a db, query that for distance and then do a lucene search that's limited to those ids? Using sql for the distance query has the added benefit of using a spatial index for improved performance. Mark On Sat, Jan 1, 2011 at 4:32 PM, Sergio Rinaudo <[email protected]> wrote: > > Hi all, > if I have the longitude and latitude stored in my lucene documents and I want > to get all the documents from the index > that are distant of a certain value from another longitude and latitude pair, > what is the best or good solution to do that? > > Thanks > > Sergio > > -- Have fun or die trying - but try not to actually die.
