Hi all:
I don't know if you have the same problem like this:
some time you need use score as default sort method,
but if you want sort by a field(such as "rank") of document or sort by a
field of document and multi by score("rank * score"). you need to extent
Searcher and overwrite TopDocs method in your own MyIndexSearcher with
customized HitColloctor.
here is example for sort result with score multi by rank field;
.......line 113
scorer.score(new HitCollector() {
public final void collect(int doc, float score) {
if (score > 0.0f && // ignore zeroed buckets
(bits==null || bits.get(doc))) { // skip docs not in bits
totalHits[0]++;
String rank = reader.doc(doc).getField("rank").stringValue();
float r = Float.parseFloat(rank);
score = score * r; //recalculate score with rank
hq.put(new ScoreDoc(doc, score)); // update hit queue
if (hq.size() > nDocs) { // if hit queue overfull
hq.pop(); // remove lowest in hit queue
}
}
}
}
}, reader.maxDoc());
...........
I think if Search have a abstract layer for Sorter and use Searcher like
search(Query,Filter,Sorter) will make lucene convenience for more
applications.
Regards
Che Dong
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>