Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 73840 invoked from network); 22 Sep 2004 13:29:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 22 Sep 2004 13:29:09 -0000 Received: (qmail 73127 invoked by uid 500); 22 Sep 2004 13:28:59 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 73037 invoked by uid 500); 22 Sep 2004 13:28:57 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 73020 invoked by uid 99); 22 Sep 2004 13:28:57 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [205.158.62.196] (HELO ws6-1.us4.outblaze.com) (205.158.62.196) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 22 Sep 2004 06:28:56 -0700 Received: (qmail 7553 invoked from network); 22 Sep 2004 13:07:53 -0000 Received: from unknown (HELO ?128.143.184.55?) (erik@hatcher.net@128.143.184.55) by ws6-1.us4.outblaze.com with SMTP; 22 Sep 2004 13:07:53 -0000 Mime-Version: 1.0 (Apple Message framework v619) In-Reply-To: <319040-220049322105919705@tegenaria.com> References: <319040-220049322105919705@tegenaria.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <73D1C5E9-0C98-11D9-B930-000393A564E6@ehatchersolutions.com> Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: Implement custom score Date: Wed, 22 Sep 2004 09:08:10 -0400 To: "Lucene Users List" X-Mailer: Apple Mail (2.619) X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Sorting is done however you specify, by field, with secondary fields specified, by document id, by score/relevance, or even by a custom implementation to sort by something else (in Lucene in Action we provide an implementation that sorts by two-dimensional distance from a given location, where documents have a "location"). So, sorting should be exactly what you want. You want to sort by a particular field: Hits hits = searcher.search(query, new Sort("popularity", true)); Does that do what you want? (the 'true' is to reverse the sort, so that you get descending popularity, which is probably what you want). In this example, the score would have no bearing whatsoever on the order of the Hits, only the "popularity" field in descending order, and document id when the popularity of documents are the same. Where are you getting that sorting is only done on 100 matches by default? We should correct the documentation if it says something like that. Erik On Sep 22, 2004, at 6:59 AM, wille@tegenaria.com wrote: > Thanks for the reply, > I've looked in to the search method that takes a Sort object as > argument. > As I understand it the sorting is only done on the best matches (100 by > default)? I don't want the default score to have any impact at all. I > want > to sort all hits on popularity not just the best matches. > > /William > >> Actually what William should use is the new Sort facility to order >> results by a field. Doing this with a Similarity would be much >> trickier. Look at the IndexSearcher.sort() methods which take a Sort >> and follow the Javadocs from there. Let us know if you have any >> questions on sorting. >> >> It would be best if you represent your 'popularity' field as an >> integer >> (or at least numeric) since sorting by String uses more memory. >> >> Erik >> >> >> On Sep 22, 2004, at 4:52 AM, Otis Gospodnetic wrote: >> >>> You need your own Similarity implementation and you need to set it as >>> shown in this javadoc: >>> http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/ >>> Similarity.html >>> >>> Otis >>> >>> --- "wille@tegenaria.com" wrote: >>> >>>> Hi, >>>> I know this is probably a common question and I've found a couple of >>>> posts >>>> about it in the archive but none with a complete answer. If there is >>>> one >>>> please point me to it! >>>> >>>> The question is that I want to discard the default scoring and >>>> implement my >>>> own. I want all the the hits to be sorted after popularity (a field) >>>> and >>>> not by anything else. How can I do this? What classes and methods do >>>> I have >>>> to change? >>>> >>>> thanks, >>>> William >>>> >>>> >>>> -------------------------------------------------------------------- >>>> - >>>> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org >>>> For additional commands, e-mail: lucene-user-help@jakarta.apache.org >>>> >>>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org >>> For additional commands, e-mail: lucene-user-help@jakarta.apache.org >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org >> For additional commands, e-mail: lucene-user-help@jakarta.apache.org >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: lucene-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org