Quick look: frange

In Solr 1.4 there were a new type of queries presented the frange queries. This new type of queries let you search for a range of values. According to the Solr developers this queries should be much faster from normal range queries. I thought that I should make a simple test to see how much faster, the new range queries can be expected to be.

Querying Solr

To use the frange query syntax we will need to modify the query. So far, the range query of the data may look as follows:


The same query made using the frange looks like this:

fq={!frange l=0 u=10000}test_si

Of course, it is also possible to send query for data types other than numbers, for example:

fq={!frange l=adam u=mariusz}name


The very logic of the test is pretty simple. The structure of the index contains two fields: id, a unique identifier and a field namestr (string), which contained the values ​​for which I will ask. I generated about 100,000 distinct documents. In addition, in each of the documents the tems in the namestr field are unique so we will easily be able to determine the percentage of terms covered by a given query. Then I started to send queries to Solr that covered a certain percentage of terms in the index. Each of the queries were send multiple times and the execution time of the queries were summed and divided by the number of queries send. The following table shows the test result:

Percent of terms coveredFaster implementationRange query execution timeFrange query execution time
100%frangeaverage 240msaverage 15ms
50%frangeaverage 105msaverage 12ms
10%frangeaverage 50msaverage 8ms
5%frangeaverage 12msaverage 12ms
1%rangeaverage 10msaverage 12ms

As you can see a standard range query is faster only for queries that cover a small number of terms from the given field. As you can see, the performance gain using the frange queries is starts from about 5% of terms covered. Interestingly, we get a nice increase in query speed, which is encouraging for even faster searching.

To sum up

The results of my test are different in terms of performance to what Yonik Seeley wrote on his blog (my test data can be the cause of this), but what we can say is that using frange queries we can expect an increase in performance for queries that need to search for a range of values.

This post is also available in: Polish

This entry was posted on Monday, May 30th, 2011 at 07:20 and is filed under Search. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.