4

I have a field called "title"

<field name="title" type="text_general" indexed="true" stored="true" required="true" omitNorms="false"/>

Here is the file definition:

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
  <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>
</analyzer>
<analyzer type="query">
 <tokenizer class="solr.StandardTokenizerFactory"/>
   <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
     <filter class="solr.LowerCaseFilterFactory"/>
     <filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>
  </analyzer>
</fieldType>

I make my query and try to sort by the [title] field. the log says:

INFO: [] webapp=/solr path=/select/ params={sort=title+asc&start=0&q="course"&wt=json&rows=15&version=2.2indent%3Don} hits=244 status=0 QTime=1

Which means my syntax is probably correct:

q="course"&amp;start=0&amp;rows=15&amp;version=2.2indent=true&amp;wt=json&amp;sort=Title%2Basc&sort=title+asc

The problem is, results do not come back sorted by the [title] field. I think I am missing something in the schema.xml file, but what?

Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
  • What you mean when saying "to sort by title"? You can sort by date (e.g. latest first), by number (e.g. largest first) or alphabetically (characters one by one, taking into account unicode characters). And how want to sort multiword title? – ffriend Mar 02 '12 at 16:16

2 Answers2

3

In general you can sort on any field that is single-valued (i.e., not tokenized (unless it uses an analyzer that produces a single term) nor multi-valued) and is indexed. So text and text_* fields are right out for sorting.

theEpsilon
  • 1,800
  • 17
  • 30
David Faber
  • 12,277
  • 2
  • 29
  • 40
1

For future reference: The field you are sorting by, should not be "too" tokenized...
I followed this article which solved my problem.

Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278