views:

27

answers:

1

How come Solr returns the "Oldest" records first when specifying these parameters.

As you probably know these are mainly for "paging" purposes.

And if I chose something like 10 Rows per page, and with the start set to 0, this means in my mind that the latest 10 records should be displayed. However, Solr displays the oldest 10 records.

How can I change this?

Thanks

+1  A: 

Solr is not a database, it is a search engine.

The order in which you get the rows is not based on the order they are inserted, but on a particular ranking algorithm.

You can find more information here:

Solr Relevancy FAQ

Why are search results returned in the order they are? If no other sort order is specified, the default is by relevancy score.

and

Solr Relevancy CookBook

You can specify a sorting order: using the sort parameter:

Examples, from the Solr Tutorial:

Solr provides a simple method to sort on one or more indexed fields. Use the 'sort' parameter to specify "field direction" pairs... 

q=video&sort=price desc 
q=video&sort=price asc 
q=video&sort=inStock asc, price desc 
volothamp
What if I would like to sort on date inserted? Would I have to create a field with the date, and then sort on that? And does it have to be indexed AND stored or only one of the above?
pesar
Also, is there any way around this, as by putting a document on top instead of at the bottom of the stack when inserting a new document? If I could get it to land on top, it would solve my problem.
pesar
No, if you want a different sort order than the Ranking, you should use one solr field. You need to store it if you want to retrieve it afterwards.
volothamp