lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Che Dong" <ched...@yahoo.com>
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 IndexOrderSearcher.java and
IndexSearch.java is IndexOrderSearcher use
(float) 1/docID as score field while just use score filter results with
minScore in search() method.
diff IndexOrderSearcher.java IndexSearch.java
66,67c66,67
< /** 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 {
71c71
<   public IndexOrderSearcher(String path) throws IOException {
---
>   public IndexSearcher(String path) throws IOException {
76c76
<   public IndexOrderSearcher(Directory directory) throws IOException {
---
>   public IndexSearcher(Directory directory) throws IOException {
81c81
<   public IndexOrderSearcher(IndexReader r) {
---
>   public IndexSearcher(IndexReader r) {
119,120c119
<             //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
159,160c158
<             //use 1/doc instead of score as sort field
<             results.collect(doc, (float) 1/doc);
---
>             results.collect(doc, score);



Mime
View raw message