Imagine an e-commerce site where you can't choose the sorting order of the results, you can only browse the search results page-by-page and nothing more. That's terrible, right? That's why with Solr you can specify the sort fields and order in which your search results should be sorted. This recipe will show you how to do it.
Let's assume that you want to sort your data by an additional field, for example, the field that contains the name of the author of the book.
First we add the following to your
schema.xml
file'sfield
section:<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="title" type="text" indexed="true" stored="true" /> <field name="author" type="string" indexed="true" stored="true"/>
Now, let's create a simple data file which will look like the following code:
<add> <doc> <field name="id">1</field> <field name="title">Solr cookbook</field...