Let's say that you have a cleaning business. Once a user types “office cleaning” on your website, the search results that show up first are some blog posts on this topic instead of the page that you're actually targeting: the “Office & Workplace Cleaning” service page. So, you wonder: “How to configure custom search in Drupal 8?”

What are your options if you want to go beyond the default Drupal search?

How can you influence that search results ordering so that you:

  • improve the overall site search experience for your visitors?
  • push forward into the spotlight particular pages on your site, based on specific keywords?

We've done our homework, collected and then selected 9 different ways that you can upgrade the default search experience in Drupal so that it should fit your needs perfectly. From:

  • additional Drupal modules that you can enable
  • to effective search plugins that you can install
  • to brilliant configurations that you can set up

… you'll find a whole collection of options at hand for fine-tuning the search functionality on your Drupal website.

1. Enable the Drupal Search API Module

If you find the default Drupal search module a bit too... restrictive, consider Search API

It takes but 3 simple steps before you can leverage its flexibility to the fullest:

  • just install it and enable it, along with the Search API database module
  • add an index and an API server, as well

2. Integrate Your Drupal 8 Website with Apache Solr Search

The Java-based search platform is powerful enough to supercharge your website with tons of search capabilities:

How to Configure Custom Search in Drupal 8: Apache Solr

Source: Drupal.org

  • search for all attributes of Drupal nodes
  • ouline the search queries in the results
  • perform language stemming to return related results
  • search across multiple websites
  • index from... millions of nodes
  • overlook users' typos and provide proper suggestions
  • provide location-based search results
  • display the most relevant results on top of the list

In short: you're better off with a Solr back-end; it will always overstep a Drupal database search setup when it comes to returning relevant and intuitive results. Even in “keyword phrase search” scenarios.

3. How to Configure Custom Search in Drupal 8: Use ExpertRec

This search-as-a-service solution ships with a heavy load of useful features, such as:

  • manageable search ranking
  • typo tolerance
  • easy UI control
  • results as you type
  • custom facets

So, you might want to consider it for evaluation. Just put its robust set of features against your site search needs. 

4. Use the Cludo Site Search Solution

What if you could turn the site search on your Drupal website into a powerful “insights generator”? 

How to Configure Custom Search in Drupal 8: Cludo

Source: Drupal.org 

One that would provide you with valuable and, most of all, actionable insights on your users' search behavior. Just imagine turning all that powerful data into highly relevant site search experiences for your visitors.

Cludo's that fully customizable on-site search tool, that “spoils” you with unique features like:

  • semantic search
  • customizable index
  • machine learning-driven autocomplete

Find out more about this tool and what it can offer you from our post on Cludo as an alternative to Google Site Search.

5. Boost the “Title” Field to Improve Search Relevancy

Say you have a “How to speed clean a kitchen” page on your website (we're assuming that you run a professional cleaning business, remember?). 

Now, if a website visitor types “how to clean my kitchen quick” you most certainly want that specific page to show up first, right?

Well, to make that happen you simply boost the title field. Here's how:

  • go to /admin/config/search/search-api
  • click “Edit”, next to the index that you're targeting
  • click “Add Fields”
  • look for “Title”, under the “Content” heading
  • hit “Done”
  • look for your title field scrolling down your list of fields and replace its “Type” from “Strong” to "Fulltext"
  • configure the “Boost” dropdown that pops up: set the title, fill in the special keywords field...
  • click the “Save Changes” button

6. Configure the Search View to Your Needs

“How to configure custom search in Drupal 8?” You tweak the default search view...

The good news is that Search API connects with Views, “spoiling” you with loads of flexibility when setting the way your search results get displayed.

But the great news is that you can go even further:

Define a field-based view, add the title and excerpts fields so that your website returns a Google-like title and snippet to its users.

7. Enable the Indexer to “See” the Whole Node

Let me guess: you, too, are using Paragraphs on your Drupal site.

Who doesn't, right? All that flexibility that you get when putting together your web pages is just... irresistible.

Then, you must have already bumped into one “minor” issue:

Your search indexer can't “see” the entire content on a page, since the Paragraphs module breaks it into multiple little pieces.

Luckily, Search API comes to the rescue! 

Just add the “Rendered HTML Output” field to your index and you'll enable the indexer to “see” the whole content on a page. Just like your website visitors see it: with references, paragraph entities and all that...

And here's how you incorporate this field:

  • go to /admin/config/search/search-api
  • click “Edit”
  • click “Fields” on top of the page
  • click “Add Fields”
  • look for “Rendered HTML Output (rendered_item)” under “General”
  • click “Add” 

Word of caution: you'll then need to select a view mode for all the content types that your search index can access. Make sure you go with the “default” mode (unless you've set up a custom mode of your own) and not the “search results highlight input”. 

8. Add a Custom “search_keywords” Field to the Targeted Content Types

Remember the example at the beginning of this post (the one with the “office cleaning” search phrase)?

Now, it's about time we found an answer to this question:

How can you give your content team more control over the returned search results? Over the results ordering...

You set up a new field called “search_keywords” and integrate it with every content-type/bundle that you're targeting:

  • go to /admin/config/search/search-api
  • click “Edit”
  • click “Fields”
  • click “Add Fields”
  • look for your newly created “Search Keywords”, under “Content”
  • click “Add”
  • look for your new field in the fields list
  • change its type from “String” to “Fulltext”
  • configure the “Boost” dropdown showing up (consider setting it to 21...)
  • click “Save Changes”

The END!

Here are no less than 9 different solutions to your “How to configure a custom search in Drupal 8?” type of dilemma.

Which one would you go with? And why?

Give us a clue in the comments here below.

Image by Republica from Pixabay  


We do Drupal development

Go to our Drupal page!

Visit page!

Browse cities

Recommended Stories

Accessibility in MarTech: A Strategic Imperative for 2024
 The importance of accessibility in MarTech goes beyond mere compliance with legal standards; it… (Read more)
5 Mins /
AI in Marketing: The Revolution
 The continuous use of AI in marketing is one of the most significant MarTech trends in 2024, driven by… (Read more)
5 mins /
 Beyond Buzzwords: MarTech Trends in 2024
 Marketing technology, or MarTech, is a collection of software and tools designed to enhance marketing… (Read more)
10 mins /