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 Che Dong <ch...@hotmail.com> on 2003/07/15 11:03:38 UTC

How to implement Similarity for custom sorting by field ( or by docID)?

Hi All: 
In lucene 1.3 rc1 release included a Similarity for custom scoring. Is it possible implement a docID based or (some field value based )scoring beside DefautlSimilarity? 

Thanks.

Che, Dong
http://www.chedong.com/tech/lucene.html

Re: How to implement Similarity for custom sorting by field ( or by docID)?

Posted by Ype Kingma <yk...@xs4all.nl>.
On Tuesday 15 July 2003 02:03, Che Dong wrote:
> Hi All:
> In lucene 1.3 rc1 release included a Similarity for custom scoring. Is it
> possible implement a docID based or (some field value based )scoring beside
> DefautlSimilarity?

Similarity is based on things that can be found in the index, and not on
things that are obtained by retrieving stored fields of documents.
In general, retrieving stored values during search is bad for search 
performance.

When you want to sort by docId you could:
- first collect all document numbers matching the query,
  evt. raise an exception when there are too many hits,
- then retrieve all documents in document nr order,
  together with the docId stored field values.
  (iirc you also get documents in doc nr order when you
  use your own results collector.)
- finally sort your results by retrieved docId.

Since one normally needs to retrieve some stored fields
anyway, this doesn't hurt performance.

Kind regards,
Ype Kingma


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