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

Efficient documents grouping using the post filter


Sometimes, the standard field collapsing provided by Solr is not enough when it comes to performance. This is especially true when we want to perform field collapsing on fields that will result in large number of unique groups in the results, so mostly, for high cardinality fields. For such use cases, Solr provides an efficient post filter approach of field collapsing, and this recipe will show you how to use that approach.

Getting ready

In this chapter, we will use the same index structure and test data as we used in the Grouping documents by the field value recipe of this chapter. Read it before we continue.

How to do it...

  1. Let's start with the index structure. Let's assume that we have the following fields in our index (just add the following section to the schema.xml files):

    <field name="id" type="string" indexed="true" stored="true" required="true" />
    <field name="name" type="text_general" indexed="true" stored="true" />
    &lt...