Drupal 8 and Solr Search

A key way to improve the search on your Drupal 8 site is to 'tag' content with Taxonomy Terms. This expands the visibility of your content and allows the content to show up when site visitors enter the term name into your site's search.

For example, you may have a blog post about Drupal, and you add the term "enterprise authoring" to it. If the post itself does not contain the words "enterprise authoring" in the body, or title, or whatever other fields you've indexed, the post will still show up in the results by virtue of having the tag. With search being an important means of helping users find content on your site, allows you to groom your content so your users find what they are looking for faster. 

The following explains how to configure Drupal 8 using the Search API and Solr to accomplish the above. 


  • Make sure you have the following modules installed and enabled: Search API, Search API Taxonomy Term Handlers, Solr Search. 
  • Make sure your site is connected and communicating with a Solr server and you have an Index set up.  
  • Make sure you've already added a taxonomy term entity reference field to the content type(s) you wish to tag. For example, you've added a field for references to the default "Free Tag" vocabulary to your 'Basic Page' content type. 
A screenshot of a section of the Drupal Administrative User Interface



If you already know a lot about this, the key to getting this to work is to make sure the Name of the entity reference field is added to the search Index as a 'Fulltext' Type. 

A picture of a page within the Drupal Administrative Interface.


Here are the steps to accomplish the above broken down:

  1. Go to the field management page for your Index (ex: Administration->Configuration->Search and metadata->Search API->Acquia Search Solr Index)
  2. Click the "Add Fields" button to open a list of fields. 
  3. Find your term reference field, in the Content section. Don't just click the "Add Field" button, instead, click the little (+) link. 
     A picture of a page within the Drupal Administrative Interface.
  4. After clicking the (+) you should get another bullet point for Taxonomy term, with an additional (+). Click that one as well. This will give you yet more bullet items. From the longer list, click the "Add" button for the Name of your field, and then the "Done" button to close out the modal. 

    A picture of a page within the Drupal Administrative Interface.


  5. Back on the field management page, you should see a new item in the Content section for the field you just added. Make sure you change the field Type to Fulltext from String. A picture of a page within the Drupal Administrative Interface.


  6. Once that is done, and you've made whatever other changes you need to make, you'll need to re-index your content. On the "View" tab for the Index is a link to "Queue all items for reindexing." Depending on your configuration, you may need to run cron a few times and clear your cache before you start seeing the taxonomy terms show up in your search results. 


Caxy Interactive is a Custom Software Development Company

See what other services Caxy has to offer.