Configuring numerical fields for high-performance sorting and range queries
Let's assume we have Apache Solr deployment where we use range queries. Some of those are run against string fields, while others are run against numerical fields. We identified that our numerical range queries are executing slower than we would like them to run. The usual question arises—is there something that we can do? Of course there is, and this recipe will show you what.
How to do it...
Let's begin with the definition of a field that we use to run our numerical range queries (we add it to the
schema.xml
file):<field name="price" type="float" indexed="true" stored="true"/>
The second step is to define the
float
field type (again, we add this to theschema.xml
file):<fieldType name="float" class="solr.TrieFloatField" precisionStep="8" />
And now the usual query that is run against the preceding field:
q=*:*&fq=price:[10.0+TO+59.00]&facet=true&facet.field=price
In order to have your numerical...