How to order search results by a tokenized field

Search results are ordered by relevance by default. This means that the better a document matches the search query, the higher it appears in the search results. In some cases, you might want to order search results by a specific field.

Example 1 - sorting by an item field:

We can use the Title field as an example. Title is a default Sitecore XP field. It is defined in Solr configuration as a text field:

Special index fields are based on Sitecore XP system fields. They usually have one or two underscores at the beginning of the field name. Such fields are defined directly in the Solr schema, for example:

In both cases, the field type definition does not include docValues and uses StandardTokenizerFactory. Tokenizers split the input value into terms. The StandardTokenizerFactory usually produces multiple terms per field: