lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Che Dong" <>
Subject IndexOrderSearcher: sort data before indexing and use 1/docID instead of score as sort field
Date Tue, 05 Mar 2002 09:37:05 GMT
Hi all:
I think many lucene user want sort lucene results on some certain field. but
just like Doug said: The problem is that a call to getField() makes searches
an order of magnitude slower.

for example: many lucene apps base on database, just sort data by date, rank
... even some complex: rank * price....
and dump into lucene index with sorted order.

when searching, with same lucene index, you can choose return search results
with two sort method:
use IndexSearcher: return results with default sort method by score
use IndexOrderSearcher: return results with doc added sequence.

I tested with (float) doc and (float) 1/doc and find 1/doc more similar to
range of score.

Che Dong

beside class name, the only difference between and is IndexOrderSearcher use
(float) 1/docID as score field while just use score filter results with
minScore in search() method.
< /** Implements search over a single IndexReader. and sort by document id*/
< public final class IndexOrderSearcher extends Searcher {
> /** Implements search over a single IndexReader. */
> public final class IndexSearcher extends Searcher {
<   public IndexOrderSearcher(String path) throws IOException {
>   public IndexSearcher(String path) throws IOException {
<   public IndexOrderSearcher(Directory directory) throws IOException {
>   public IndexSearcher(Directory directory) throws IOException {
<   public IndexOrderSearcher(IndexReader r) {
>   public IndexSearcher(IndexReader r) {
<             //use 1/doc instead of score as sort field
<             hq.put(new ScoreDoc(doc,  (float) 1/doc));          // update
hit queue
>             hq.put(new ScoreDoc(doc, score));   // update hit queue
<             //use 1/doc instead of score as sort field
<             results.collect(doc, (float) 1/doc);
>             results.collect(doc, score);

View raw message