lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: Sort by relevance+distance
Date Mon, 19 Sep 2005 07:19:24 GMT
On Sep 18, 2005, at 3:39 PM, James Huang wrote:
> So the question is, is there a way to overriding score
> calculation at runtime? In the lucene/search package,
> I see interfaces like Scorer, Weight and methods like
> Query.createWeight(). This looks promising.

You indeed need to override the following things:
- Query (changes for createWeight() (), the query location, the normal Lucene 
query)
- Weight (this will probably not do very much in your case, except for passing 
things to your scorer)
- Scorer

Iirc, you only need an extra score factor depending on the distance,
where the query contains a location.
That means you need something like a ConjunctionScorer
to combine the scores of the query parts with and without the distance.
The part without the distance is a standard lucene query in your case (iirc).
For the part with the distance, you'll need the actual document locations
(preferably in RAM) and compute the distance based score factor based
on those locations and the query location.

One way to have these document locations in RAM is by using a field cache,
much like the sorting code does.

In case the query also has constraints on the location the query search might
take advantage of that, but that would need more development, for example
starting from RangeQueries and/or filters on the location coordinates.

Regards,
Paul Elschot


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message