DataStax Help Center

Tuning Solr facet queries with warmers

Summary

Heavy and concurrent use of facet queries on Solr, particularly on fields with high cardinality, can acquire high latency when auto soft commit is triggered.  Setting up new searchers to warm your facet queries will improve response times.  However, with facet queries, this is an all or none scenario and you will need to set up warming queries on all your facet queries for it to be effective.

Cause

The reason for this is that after each commit/flush the new searcher needs to reload from a data structure on disk.  There is no concurrency on this operation.  Even if you have some of the facet queries warmed they will still contend with non-warmed queries and you won't see performance benefit.

Solution

Setting up a warming query for all your facets resolves this performance issue.  After each commit/flush the warmers will get executed one by one while current queries run on the old warmed searchers.  To mitigate high use of memory by the warmers it is best to limit the facet, for instance to 1, and to restrict the search if possible.

Example

The below is a simplified example implementation.

Excerpt from schema.xml

<field name="title"  type="text" indexed="true"  stored="true"/>
<field name="topic"  type="text" indexed="true"  stored="true"/>
<field name="subject"  type="text" indexed="true"  stored="true"/>

Queries

http://<hostname>:8983/solr/<keyspace>.<table>/select?q=*%3A*&wt=xml&indent=true&defType=edismax&facet=true&facet.field=topic&facet.limit=10&rows=0
http://<hostname>:8983/solr/<keyspace>.<table>/select?q=*%3A*&wt=xml&indent=true&defType=edismax&facet=true&facet.field=title&facet.limit=10&rows=0
http://<hostname>:8983/solr/<keyspace>.<table>/select?q=*%3A*&wt=xml&indent=true&defType=edismax&facet=true&facet.field=subject&facet.limit=10&rows=0

Excerpt from solrconfig.xml

<listener event="newSearcher" class="solr.QuerySenderListener"> 
<arr name="queries"> 

<lst><str name="q">prewarmQuery</str> 
<str name="facet">true</str> 
<str name="facet.limit">1</str> 
<str name="facet.field">topic</str></lst>

<lst><str name="q">prewarmQuery</str> 
<str name="facet">true</str> 
<str name="facet.limit">1</str> 
<str name="facet.field">title</str></lst> 

<lst><str name="q">prewarmQuery</str> 
<str name="facet">true</str> 
<str name="facet.limit">1</str> 
<str name="facet.field">subject</str></lst> 
</arr> 
</listener> 
  <autoSoftCommit>
       <maxTime>30000</maxTime>
  </autoSoftCommit> 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk