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...
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...