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

Lowering the memory consumption of faceting and sorting


Faceting and sorting might require a large amount of RAM memory for large volumes of documents. For sorting or faceting, Solr needs to un-invert the values in the index and keep such information in memory—in the field cache. This might require a significant amount of memory when your data is large enough. Of course, you can scale out, have more nodes, and spread the collection among them so that a single Solr instance is put under less pressure. However, Lucene introduced a special structure called doc values, which can work as fast as field cache, but doesn't require as much memory. This recipe will show you how to use this.

How to do it...

For the purpose of this recipe, let's assume that we have a bookstore and we allow a user to sort on the title of the book:

  1. Our initial index structure (the field's definition section from the schema.xml file) looks as follows:

    <field name="id" type="string" indexed="true" stored="true" required...