lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khawaja Shams" <kssh...@gmail.com>
Subject Re: Sorting documents without a query
Date Sun, 07 Dec 2008 01:21:05 GMT
Hi Shivaraj,   I would recommend John's approach and let Lucene deal with
the sorting.


Nonetheless, you can traverse through the terms by using the following
method:
http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexReader.html#terms(org.apache.lucene.index.Term)

Basically, you should pass in a term with your price field name and an empty
string for the value. You would traverse the enumeration until you hit a
Term with a different field name. You can get the documents with the term by
using:
http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexReader.html#termDocs(org.apache.lucene.index.Term)



Hope that helps.

Khawaja

On Sat, Dec 6, 2008 at 4:21 PM, Shivaraj Tenginakai <tshivaraj@gmail.com>wrote:

> Thanks John,
>
> MatchAllDocsQuery works, however I was unable to locate an example for
> traversing the term table. Could you please point me to one?
>
> Regards,
>
> Shivaraj
>
>
>
> On Fri, Dec 5, 2008 at 4:35 AM, John Wang <john.wang@gmail.com> wrote:
>
> > The obvious way is to use use MatchAllDocsQuery with Sort parameters on
> the
> > searcher, e.g.
> >
> > searcher.search(new MatchAllDocsQuery(),sort);
> >
> > If you only care about 1 sort spec (e.g. no secondary sort to break ties)
> > it
> > may be faster just traversing the term table since that is already
> sorted.
> >
> > -John
> >
> > On Thu, Dec 4, 2008 at 11:12 PM, Shivaraj Tenginakai <
> tshivaraj@gmail.com
> > >wrote:
> >
> > > I have a usecase in which I have no search query, but still need to
> sort
> > > documents. For example, items need to be sorted by price, though the
> user
> > > has not yet selected any search criteria.
> > >
> > > What would be the best way to achieve this?
> > >
> > > Thanks and Regards,
> > >
> > > Shivaraj
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message