Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Promote Results by Keyword

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:04
    One of the benefits of building our own search application
  • 0:07
    is that we have the ultimate control over ranking of items
  • 0:10
    returned for any particular search query.
  • 0:12
    So if we combine that with our superior knowledge of our own content,
  • 0:16
    we can use this to ensure that when someone performs a search for a specific keyword,
  • 0:20
    we can bubble up the most relevant results to the top
  • 0:24
    regardless of whatever Solr might have ranked those as based on its internal algorithms.
  • 0:30
    Another common use case for this idea of promoted search results
  • 0:35
    is things like the sponsored results on a Google search.
  • 0:39
    When you perform a search for certain keywords,

Promote Results by Keyword

Loading...

One of the benefits of building our own search application is that we have ultimate control over the ranking of items. Combined with our superior knowledge of our own content we can use this to ensure that when someone searches for a specific keyword we bubble our best content for that term to the top of the list, regardless of whatever Solr might rank it based on its internal algorithms. This is commonly referred to as promoted, or sponsored, results; the artificial boosting of a particular document to the top of the result list for a specific query.

A similar, but not exactly the same, example would be sponsored results on Google searches, where you can pay to have your page listed at the top of the results for a specific keyword or set of keywords. We are going to be doing all of this except for the part where we let people pay to promote results, though you could certainly build that part on your own if you need that.

Solr uses a configuration file named elevate.xml, in conjunction with a processor, to elevate results at the time a query is performed. We can promote specific documents in our Solr index by figuring out the unique Solr ID for a document and then adding it to the elevate.xml file along with some information about a query, or queries, this document should be promoted for.

In this tutorial we'll learn how to find a Solr document's unique ID, and then configure Solr to use an elevate.xml file that will promote the "How to Use the Fish Finder" page to the top of the results when someone searches for the term "fish". This configuration is all within the Solr application itself and doesn't really rely on Drupal in anyway. As such, the material in this tutorial should be applicable to your Solr search applications even if you're not building them with Drupal.

By the end of this lesson you should be able to configure promoted documents in your own Solr-based search application.

Downloads: 
Log in or sign up to download companion files.