Over a million developers have joined DZone.

Solr Optimization – query result window size

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

Hereby I would like to start a small series of articles describing the elements of the optimization of Solr instances. At first glance I decided to describe the parameter that specifies the data fetch window size – the query result window size. Hopefully, this article will explain how to use this parameter, how to modify and adapt it to your needs.

The begining

To start talking about this configuration parameter, we must first say how Solr fetches results from the index. When passing the rows parameter to Solr, with the value of 20 for example, we tell Solr that we want the result list to contain the maximum of 20 documents. However, the number of results, which was taken from the index varies and is determined precisely by the queryResultWindowSize parameter. This parameter, defined in the solrconfig.xml file, determines how many results will be retrieved from the index and stored in queryResultCache.

But what can I use queryResultWindowSize for ?

The queryResultWindowSize parameter specifies the size of so called results window, which is simply the number of documents that will be fetched from the index when retrieving search results.  For example, setting queryResultWinwdowSize to 100 and send the following query:


will result in a maximum of 30 documents in the search result list, however Solr will fetch 100 documents from the index (starting at index 0 and ending at index 100) and then try Solr will place them in queryResultCache. The next query, which will differ only in the parameters start and rows can be retrieved from queryResultCache.


To set the queryResultWindowSize to the value of 100, you must add the following entry to the solrconfig.xml file:


What to remember ?

Of course, setting only the queryResultsWindowSize is not everything. You should still provide adequate space in queryResultCache for Solr to be able to store the necessary information. However queryResultCache configuration is a topic for another article.

But why use it ?

The answer to that question is quite simple – if your application and your users often use the paging it is reasonable to consider changing the default value of the queryResultWindowSize. In most cases, where the implementation was based on paging, changing the value of this parameter caused a severe increase in performance when switching between query pages of the results.

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!


Published at DZone with permission of Rafał Kuć, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}