Removing filters from faceting results
Let's assume for the purpose of this recipe, you have an application that can search for companies within a city and a state. However, the requirements say that not only should you show the search results, but also the number of companies in each city and the number of companies in each state (to say in the Solr way—you want to exclude the filter query from the faceting results). Can Solr do this efficiently ? Sure it can, and this recipe will show you how to do it.
Getting ready
Before you start reading this recipe, let's take a look at the Getting the number of documents with the same field value recipe of this chapter.
How to do it...
As usual we start with a very simple index structure that contains four fields. We do this by adding the following section to the
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...