Apache Solr: How to Use the Query Elevation Component

0
110

Solr provides an in-built search component which moves specific documents to the top of the search results for particular queries. This component can also be used to exclude some documents for particular queries. This component in Apache Solr, named as Query Elevation Component. This search component provides the capability to spot-fix the problematic queries for which the default search scoring method does not return the result in order what your customers are expecting or could be more relevant documents are coming in bottom rather then on top. This search component can be considered as one of the available features to improve the scoring of some documents for which particular queries are not generating high scores by default.


This search component lets you promote some specific products/articles to appear as top results for a given search term regardless of their original ranking.


This component is sometimes referred to as “sponsored search”, “editorial boosting”, “best bets”, “featured results” or “premium results”. This component actually matches the user query text to a configured map of top results. The text can be any string or non-string IDs, but it should be indexed. Although this component can be use with any QueryParser, but it is always best to use it with DisMax or eDisMax. The Query Elevation Component works well with distributed searching as well.

Some use cases

  • Promote best selling products on e-commerce.
  • Promote new service, product or event in order to increase the conversion rate.
  • Advertising.

Configuring the Query Elevation Component

As a first step to use the Query Elevation Component, one has to enable it in solrconfig.xml by adding the below section:

image3.png

The Query Elevation Search Component takes the following arguments:

        Argument          Description
          Query FieldType          Specifies which fieldType should be used to analyze the incoming text.          For example, it may be appropriate to use a fieldType with a LowerCaseFilter.
          config-file          Path to the file that defines query elevation. This file must exist in           <instanceDir>/conf/<config-file> or <dataDir>/<config-file>. If the file exists           in the /conf/ directory it will be loaded once at startup. If it exists in the data           directory, it will be reloaded for each IndexReader.
          forceElevation          By default, this component respects the requested sort parameter: if the           request asks to sort by date, it will order the results by date.          If forceElevation=true (the default), results will first return the boosted docs,           then order by date.

elevate.xml

Elevated query results are configured in an external XML file specified in the config-file argument. An elevate.xml file might look like this:

image2.png

In the above example, the query “foo bar” would first return documents 1, 2 and 3, then whatever normally appears for the same query. For the query “ipod“, it would first return “MA147LL/A”, and would make sure that “IW-02” is not in the result set.

Results for sample query “ipod” – Without elevation component

image1.png

Results for sample query “ipod” – With elevation component

image4.png

Conclusion:

One of the great features of SOLR is the ability for doing promoted or recommended searches. With this helpful feature, you are able to use basically a kind of query (elevation query), that is able to elevate static searches configured by id. If you do not feel comfortable with the SOLR configurations and management you can hire Solr support and Solr consulting service provider who can implement full-text-search, geospatial searching, multiple search indexing, and other Solr search functions that make faster and more accurate searching on your project.

LEAVE A REPLY

Please enter your comment!
Please enter your name here