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.

Configure Synonyms in Solr

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

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

Log in Sign up
  • 0:03
    In this tutorial, we're going to take a look
  • 0:06
    at configuring synonyms in Solr.
  • 0:09
    We'll talk about what the use case for synonyms is
  • 0:12
    and why you might want to use them with your search configuration.
  • 0:15
    And then we'll look at how to set Solr up to use
  • 0:18
    synonyms when indexing your content.
  • 0:21
    So a synonym is any instance where you've got two variations of one word that basically mean the same thing.
  • 0:29
    A Drupal example might be configuration management is the same as CMI.
  • 0:36
    So when somebody performs a search on drupalize me for the string configuration management,
  • 0:41
    I would want to return a set of results that includes the key words configuration management

Configure Synonyms in Solr


Solr provides the option to configure synonyms for use during both indexing and querying of textual data. A synonym is a word or phrase that means exactly or nearly the same thing as another word or phrase in the same language. For example, shut is a synonym of close. Synonyms, if not accounted for, can cause a dilution of search result relevancy when searching for a keywords that have lots of variations in your index.

Consider for example the words, "ipod", "i-pod", and "i pod". It's pretty easy to imagine a scenario in which the content of our site could contain all three variations of the word. When someone searches though they are likely just going to search for one, but expect results for all three. In order to not break those expectations we need to make sure we account for this scenario. Another example from the the Drupal world would be the terms "CMI" and "configuration management". Chances are if you search for one you would be happy to see results for the other.

In this tutorial we'll look at using the synonyms.txt file that is part of our Solr configuration in order to account for synonyms in our data. Of course the exact words you use will depend on the content of your site, but we can at least cover how they work and how to configure them.

By the end of this tutorial you should be able to configure Solr to be aware of synonyms in your data in order to improve the quality of your search results.

Log in or sign up to download companion files.