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 Dmytro Barabash <d....@gmail.com> on 2011/03/30 12:35:20 UTC
Spatial search: collect distances
Hi all!
I need 1) sort search results by distance from some point and 2) show
these distances for end-user together with other document information.
1) is simple – like an example in “Lucene in action”: there are
latitude and longitude fields for each document in index,
MyDistanceComparatorSource (extends FieldComparatorSource) return
MyDistanceScoreDocLookupComparator, which know how to calculate and
compare distances, and MyDistanceComparatorSource pass to Sort’s
constructor. Sorting is fine.
For 2) I probably should write MyCollector – wrapper for
TopFieldCollector, that will collect information about distances.
But how (nice) to get already calculated distances in MyCollector, if
these distances are so deeply (in topFieldCollector.comparator)? Or
maybe this way is wrong?
Thanks in advance!
Dmytro
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Spatial search: collect distances
Posted by Dmytro Barabash <d....@gmail.com>.
I am sorry to trouble, problem solved (in fact problem is absent :) ).
Calculated distances saved in ScoreDoc (actually FieldDoc).
2011/3/30 Dmytro Barabash <d....@gmail.com>:
> Hi all!
> I need 1) sort search results by distance from some point and 2) show
> these distances for end-user together with other document information.
> 1) is simple – like an example in “Lucene in action”: there are
> latitude and longitude fields for each document in index,
> MyDistanceComparatorSource (extends FieldComparatorSource) return
> MyDistanceScoreDocLookupComparator, which know how to calculate and
> compare distances, and MyDistanceComparatorSource pass to Sort’s
> constructor. Sorting is fine.
> For 2) I probably should write MyCollector – wrapper for
> TopFieldCollector, that will collect information about distances.
> But how (nice) to get already calculated distances in MyCollector, if
> these distances are so deeply (in topFieldCollector.comparator)? Or
> maybe this way is wrong?
> Thanks in advance!
> Dmytro
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org