Reverse sorting by index order

View: New views
6 Messages — Rating Filter:   Alert me  

Reverse sorting by index order

by Oren Shir :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

If I understand correctly, when sorting by Sort.INDEXORDER the oldest
documents that were added to the index will be returned first. I want the
reverse, because I'm more interested in newer documents.

1) Is there a simple way?

2) Will going over the Hits object in reverse order be much more consuming?

Thanks,
Oren Shir

Re: Reverse sorting by index order

by Andy Lee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 3, 2005, at 9:37 AM, Oren Shir wrote:
> If I understand correctly, when sorting by Sort.INDEXORDER the oldest
> documents that were added to the index will be returned first. I  
> want the
> reverse, because I'm more interested in newer documents.

Looking at the source, I see that Sort.INDEXORDER is simply an  
instance of Sort:

   public static final Sort INDEXORDER = new Sort(SortField.FIELD_DOC);

Haven't tried this myself, but you could create your own instance  
that uses a reverse sort:

   Sort reverseIndexOrder = new Sort(SortField.FIELD_DOC, true);

And use that wherever you were using Sort.INDEXORDER.

--Andy


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@...
For additional commands, e-mail: java-user-help@...


Re: Reverse sorting by index order

by Oren Shir :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

There is no constructor for Sort(SortField, boolean) in Lucene API. Which
version are you using?

Thanks,
Oren Shir

On 11/3/05, Andy Lee <aglee@...> wrote:

>
> On Nov 3, 2005, at 9:37 AM, Oren Shir wrote:
> > If I understand correctly, when sorting by Sort.INDEXORDER the oldest
> > documents that were added to the index will be returned first. I
> > want the
> > reverse, because I'm more interested in newer documents.
>
> Looking at the source, I see that Sort.INDEXORDER is simply an
> instance of Sort:
>
> public static final Sort INDEXORDER = new Sort(SortField.FIELD_DOC);
>
> Haven't tried this myself, but you could create your own instance
> that uses a reverse sort:
>
> Sort reverseIndexOrder = new Sort(SortField.FIELD_DOC, true);
>
> And use that wherever you were using Sort.INDEXORDER.
>
> --Andy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@...
> For additional commands, e-mail: java-user-help@...
>
>

Re: Reverse sorting by index order

by Andy Lee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 3, 2005, at 10:22 AM, Oren Shir wrote:
> There is no constructor for Sort(SortField, boolean) in Lucene API.  
> Which
> version are you using?

I think 1.9rc1.  I have a pretty recent svn checkout -- maybe this  
constructor is new.

--Andy



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@...
For additional commands, e-mail: java-user-help@...


Re: Reverse sorting by index order

by Oren Shir :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I use 1.4.3 . Any other options?

On 11/3/05, Andy Lee <aglee@...> wrote:

>
> On Nov 3, 2005, at 10:22 AM, Oren Shir wrote:
> > There is no constructor for Sort(SortField, boolean) in Lucene API.
> > Which
> > version are you using?
>
> I think 1.9rc1. I have a pretty recent svn checkout -- maybe this
> constructor is new.
>
> --Andy
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@...
> For additional commands, e-mail: java-user-help@...
>
>

Re: Reverse sorting by index order

by Oren Shir :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've found the answer. Thanks to Andy Lee for giving me the idea to look
inside Lucene's code. The line is

new Sort(new SortField(null, SortField.DOC, true))

What got me confused is the null in the constructor, but I see that's the
way it is used in SortField.

Oren Shir

On 11/3/05, Oren Shir <shoren@...> wrote:

>
> I use 1.4.3 . Any other options?
>
> On 11/3/05, Andy Lee <aglee@...> wrote:
> >
> > On Nov 3, 2005, at 10:22 AM, Oren Shir wrote:
> > > There is no constructor for Sort(SortField, boolean) in Lucene API.
> > > Which
> > > version are you using?
> >
> > I think 1.9rc1. I have a pretty recent svn checkout -- maybe this
> > constructor is new.
> >
> > --Andy
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@...
> > For additional commands, e-mail: java-user-help@...
> >
> >
>