You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by user 01 <us...@gmail.com> on 2013/10/08 00:09:52 UTC

Fix sort order within an index ?

Any way to store documents in a fixed sort order within the indexes of
certain fields(either the arrival order or sorted by int ids, that also
serve as my unique key), so that I could store them optimized for browsing
lists of items ?

The order for browsing is always fixed & there are no further filter
queries. Just I need to fetch the top 20 (most recently added) document
with field value topic=x1

I came across this article & a JIRA issue which encouraged me that
something like this may be possible:

http://shaierera.blogspot.com/2013/04/index-sorting-with-lucene.html

https://issues.apache.org/jira/browse/LUCENE-4752

Re: Fix sort order within an index ?

Posted by user 01 <us...@gmail.com>.
@Upayavira:

>q=topic:x1&rows=20&sort=id desc
>Or
>q=topic:x1&rows=20&sort=timestamp desc
>
>Will get you what you ask for.

yeah I know that I could use SORT & that will work but I asked just for an
optimized way. Also that ticket has been fixed, so shouldn't be able to now
make use of the fixed sort order?


On Tue, Oct 8, 2013 at 11:59 AM, Upayavira <uv...@odoko.co.uk> wrote:

>
>
> On Mon, Oct 7, 2013, at 11:09 PM, user 01 wrote:
> > Any way to store documents in a fixed sort order within the indexes of
> > certain fields(either the arrival order or sorted by int ids, that also
> > serve as my unique key), so that I could store them optimized for
> > browsing
> > lists of items ?
> >
> > The order for browsing is always fixed & there are no further filter
> > queries. Just I need to fetch the top 20 (most recently added) document
> > with field value topic=x1
> >
> > I came across this article & a JIRA issue which encouraged me that
> > something like this may be possible:
> >
> > http://shaierera.blogspot.com/2013/04/index-sorting-with-lucene.html
> >
> > https://issues.apache.org/jira/browse/LUCENE-4752
>
> That ticket is an optimisation. If your IDs are sequential, you can sort
> on them. Or you can add a timestamp field with a default of NOW, and
> sort on that.
>
> q=topic:x1&rows=20&sort=id desc
> Or
> q=topic:x1&rows=20&sort=timestamp desc
>
> Will get you what you ask for.
>
> The above ticket might just make it a little faster.
>
> Upayavira
>

Re: Fix sort order within an index ?

Posted by Upayavira <uv...@odoko.co.uk>.

On Mon, Oct 7, 2013, at 11:09 PM, user 01 wrote:
> Any way to store documents in a fixed sort order within the indexes of
> certain fields(either the arrival order or sorted by int ids, that also
> serve as my unique key), so that I could store them optimized for
> browsing
> lists of items ?
> 
> The order for browsing is always fixed & there are no further filter
> queries. Just I need to fetch the top 20 (most recently added) document
> with field value topic=x1
> 
> I came across this article & a JIRA issue which encouraged me that
> something like this may be possible:
> 
> http://shaierera.blogspot.com/2013/04/index-sorting-with-lucene.html
> 
> https://issues.apache.org/jira/browse/LUCENE-4752

That ticket is an optimisation. If your IDs are sequential, you can sort
on them. Or you can add a timestamp field with a default of NOW, and
sort on that.

q=topic:x1&rows=20&sort=id desc
Or
q=topic:x1&rows=20&sort=timestamp desc

Will get you what you ask for.

The above ticket might just make it a little faster.

Upayavira