Hi Yonik, Thanks very much for your suggestion. The query boost works great for keyword matching. But in my case, I need to rank the results by date and title. For example, title:foo^2 abstract:foo^1.5 date:2004^3 will only boost the document with date=2004. What I need is boosting the "distance" from the specified date which means 2003 will have a better ranking than 2002, 2002>2001, etc. I implemented a customized ScoreDocComparator class which works fine for one field. But I met some trouble when trying to combine other fields together. I'm still looking at FunctionQuery. Don't know if I can figure out something. Any suggestions? Thanks.
Yang -----Original Message----- From: Yonik Seeley [mailto:[EMAIL PROTECTED] Sent: 2006年3月8日 21:35 To: java-user@lucene.apache.org Subject: Re: Lucene Ranking/scoring Hi Yang, Boosting works at query time as well as index time. If you are using the QueryParser, specify boosts like so: title:foo^2 abstract:foo^1.5 date:mydate^3 If you are building queries pragmatically, then use the Query.setBoost() method. That will boost relative to how a non-boosted query would score, but keep in mind that you still have tf/idf factors in the score. If you need to get rid of the tf/idf factors, either write your own ScoreDocComparator, or use a FunctionQuery. -Yonik http://incubator.apache.org/solr Solr, The Open Source Lucene Search Server On 3/8/06, Yang Sun <[EMAIL PROTECTED]> wrote: > Hi, > Just wondering how I can rank search result by a combination of fields. I > know there is a multi-field sort, but it is just a sorting method. It is > sorted by the first field and then the second field ... > What I need is a weighted combination. For example, I want to assign a > weight of 2 to title match, 1.5 to abstract match, and 3 to date match (i. e. > How close the last modified date). The final score will be > 2*inTitle+1.5*inAbstract+3*date instead of sorting by date and then sorting > by title within the same date. > I checked lucene Score, Similarity, and SortDocComparator and can't find an > answer. Implements the SortDocComparator seems the closest, but it can only > sort the result by one field. The Field boost does not work because the > boosting factor has to be set during index time. What I need is setting the > weight at query time. > Please help. Thanks. > > Yang --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]