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

Implementing the autocomplete functionality for categories


Sometimes, we are interested not in our product's name for autocomplete, but in something else. Imagine that we want to show the category of our products in the autocomplete box along with the number of products in each category. Let's see how we can use faceting to achieve such functionality.

How to do it...

  1. Let's start with the example data, which is going to be indexed and looks as follows:

    <add>
     <doc>
      <field name="id">1</field>
      <field name="name">First Solr Cookbook</field>
      <field name="category">Books</field>
     </doc>
     <doc>
      <field name="id">2</field>
      <field name="name">Second Solr Cookbook</field>
      <field name="category">Books And Tutorials</field>
     </doc>
     <doc>
      <field name="id">3</field>
      <field name="name">Elasticsearch Server</field>
      <field name="category">Books And Tutorials...