lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Albert Clemente Peláez <>
Subject Order by distance on Spatial Searches (porting from Lucene4 Java)
Date Fri, 16 Nov 2012 09:19:57 GMT


A few days ago I started using spatial searches with 3.0.3 release and the Spatial Contrib
+ Spatial4N.


Although I found some starting problems, It finally worked great when I understood that the
Spatial Contrib was based on the new Spatial of Lucene 4 for Java.



My problem now is that although I can search by proximity, I cannot order by distance, and
that is due to it hasn't been ported the type SortField.REWRITABLE and the ValueSourceComparatorSource
and ValueSourceComparator that able to order by distance on spatial searches.



I'm just trying that these staff works (sample from java):


    //--Match all, order by distance


      Point pt = ctx.makePoint(60, -50);

      ValueSource valueSource = strategy.makeDistanceValueSource(pt);//the distance (in degrees)

      Sort reverseDistSort = new sort(valueSource.getSortField(false)).rewrite(indexSearcher);//true=asc

      TopDocs docs = MatchAllDocsQuery(), 10, reverseDistSort);

      assertDocMatchedIds(indexSearcher, docs, 4, 20, 2);




If I port this java classes and functions to and Contrib.Spatial, I'd like that
it would be include in the final release, just to be sure we will be able to continue upgrading
to future releases without recoding our apps.


Please let me know If I'm not right or If you know a better aproach for ording by distance.






Albert Clemente




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message