Book Image

Solr Cookbook - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition

By: Rafal Kuc

Overview of this book

Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring sorting for non-English languages


As you might already know that Solr supports UTF-8 encoding and thus can handle data in many languages. However, if you ever needed to sort some languages that have characters specific to them, you probably know that it doesn't work well on the standard Solr string type. This recipe will show you how to deal with sorting and Solr.

How to do it...

  1. For the purpose of this recipe, I assumed that we will have to sort text that contains Polish characters. To show good and bad sorting behavior, we need to create the following index structure (add this to your schema.xml file):

    <field name="id" type="string" indexed="true" stored="true" required="true" />
    <field name="name" type="text_general" indexed="true" stored="true" />
    <field name="name_sort_bad" type="string" indexed="true" stored="true" />
    <field name="name_sort_good" type="text_sort" indexed="true" stored="true" />
  2. Now let's define some copy fields to automatically fill...