Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 41239 invoked from network); 12 Nov 2008 03:18:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Nov 2008 03:18:41 -0000 Received: (qmail 33787 invoked by uid 500); 12 Nov 2008 03:18:42 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 33746 invoked by uid 500); 12 Nov 2008 03:18:42 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 33730 invoked by uid 99); 12 Nov 2008 03:18:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Nov 2008 19:18:42 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of zzzhc.starfire@gmail.com designates 209.85.142.185 as permitted sender) Received: from [209.85.142.185] (HELO ti-out-0910.google.com) (209.85.142.185) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Nov 2008 03:17:23 +0000 Received: by ti-out-0910.google.com with SMTP id b8so96034tic.11 for ; Tue, 11 Nov 2008 19:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=dD4AwX+7gLUjUGWvpU1nyIqiJYWLHzzuSqXIK8/hPro=; b=J3O+Of3mnLZlMyRZdfYleMb5QmO1GXsIz2/zl2EADLEKXD8pKNrmkb+X9hNUTD/Gz3 dp4fanYv5vA5cCUlROlmSC9jByhrZJq8+RnVQcuY6b5AAJYTQ+4xNrYhzjTIqTP/IlM2 Rf0oGpCe6vlsiMjmkT+U5GQEIhobIs25vRyBk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=vT5Xt2IVn3vADzpHA5aiH8HahlD/qSy4Ccl9av7+RvPi4fIPODsIEGWO+GKK7mY/Nl FkNJuSbi+vtRilyDGg1AGi4OrkIJLqHrGWTLOztNZcIIDamHsBIsghWlsmgorjb5xCKu G0fWNaAvc7CIsKGtv71SLu+RzW8TXrAXzb1zI= Received: by 10.110.49.6 with SMTP id w6mr10321413tiw.9.1226459875542; Tue, 11 Nov 2008 19:17:55 -0800 (PST) Received: by 10.110.47.20 with HTTP; Tue, 11 Nov 2008 19:17:55 -0800 (PST) Message-ID: <4397aa520811111917n62782964x1601e01a7e4e67b2@mail.gmail.com> Date: Wed, 12 Nov 2008 11:17:55 +0800 From: "=?GB2312?B?u8azyQ==?=" To: java-user@lucene.apache.org, techcool.kumar@yahoo.com Subject: Re: Order the index by timestamp field and Get n documents In-Reply-To: <807889.52342.qm@web110303.mail.gq1.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_92861_11389549.1226459875523" References: <962306.88258.qm@web110313.mail.gq1.yahoo.com> <807889.52342.qm@web110303.mail.gq1.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_92861_11389549.1226459875523 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I think you should use NumberTools to format timestamp first, otherwise sort will not work correctly On Mon, Nov 10, 2008 at 8:00 PM, Cool The Breezer wrote: > Could able to do that using range query > > String end = "253373251260000";//i.e. 11/30/9999, assume that this is max > end date > > Term endTerm = new Term("timestamp",end); > RangeQuery rangeQuery = new RangeQuery(null,endTerm,true); > > Sort sort = new Sort("timestamp",true); > Filter dupFilter = new DuplicateFilter("id"); > Hits hits = searcher.search(rangeQuery,dupFilter,sort); > > > > > --- On Mon, 11/10/08, Cool The Breezer wrote: > > > From: Cool The Breezer > > Subject: Order the index by timestamp field and Get n documents > > To: java-user@lucene.apache.org > > Date: Monday, November 10, 2008, 1:21 AM > > Hi, > > In my index, there is a field called timestamp which is > > long value of date. I am trying to get sort all documents > > by timestamp and get N documents. > > I am trying to find a way to create a query like > > "timestamp > 0" and then order the result by > > timestamp and get N fields. However I am not able to do > > that. Suggest me the best way. Or there are any lowlevel > > method available for the same. > > > > I am using Lucene 2.3.1 and looking into method > > search(Weight weight, Filter filter, int nDocs, Sort sort) > > in IndexSearcher. Trying to know how to create a Weight > > object. > > > > Anyway, I would really appreciate your suggestion.... > > > > -RB > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > java-user-unsubscribe@lucene.apache.org > > For additional commands, e-mail: > > java-user-help@lucene.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > ------=_Part_92861_11389549.1226459875523--