Configuration
solrconfig.xml
The query elevation component is configured in solrconfig.xml. A typical configuration may look like:
<searchComponent name="elevator" class="org.apache.solr.handler.component.QueryElevationComponent" >
<str name="queryFieldType">string</str>
<str name="config-file">elevate.xml</str>
</searchComponent>
<requestHandler name="/elevate" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
<arr name="last-components">
<str>elevator</str>
</arr>
</requestHandler>
Available arguments for the searchComponent are:
queryFieldType
Configure which fieldType should be used to analyze the incoming text. For example, it may be appropriate to use a fieldType with aLowerCaseFilter.
config-file
Path to the file that defines query elevation. This file must exist in:
<!--[if !supportLists]-->1. <!--[endif]-->${instanceDir}/conf/${config-file} , or
<!--[if !supportLists]-->2. <!--[endif]-->${dataDir}/${config-file}
If the file exists in the /conf/ directory it will be loaded once at start-up. If it exists in the data directory, it will be reloaded for eachIndexReader.
forceElevation
By default, this component respects the requested 'sort' parameter -- that is, if the request asks to sort by date, it will order the results by date. If forceElevation=true, results will first return the boosted docs, then order by date.
elevate.xml
Elevated query results are configured in an external .xml file determined by the config-file argument. An elevate.xml file may look like this:
<elevate>
<query text="AAA">
<doc id="A" />
<doc id="B" />
</query>
<query text="ipod">
<doc id="A" />
<!-- you can optionally exclude documents from a query result -->
<doc id="B" exclude="true" />
</query>
</elevate>
For the above configuration, the query "AAA" would first return documents A and B, then whatever normally appears for the same query. For the query "ipod", it would first return A, and would make sure that B is not in the result set.
Usage
All standard solr features such as faceting, sorting, and MoreLikeThis work with this component installed.
enableElevation
For debugging it may be useful to see results with and without the elevated docs. To hide results use "enableElevation=false", like this:
fq
Query elevation respects the standard "filter query" (fq) parameter. That is, if the query contains a fq parameter, all results will be within that filter even if elevate.xml adds other documents to the result set.