Skip to main content
Understanding Drupal core search

Understanding Core Search: Helping You Users Find What They Need

Let's face it, it doesn't matter how pretty your new website is or what kind of bells and whistles you've built to get business done. If your users can't find what they are looking for, they will leave and find it somewhere else! That's why it's critical that your site have some sort of search capabilities.

First, let me clarify, by search, I'm not talking about search engines such as Google or Bing. I'm talking about in-site search where the user is on your website and is looking for some specific product or service that you offer. Search engine optimization is a whole different section of your website plan.

Search Options for Drupal

When choosing how your site will be searched, there are a couple of options to choose from in Drupal. Choosing the right solution is a delicate combination of results accuracy, required features, technical support requirements, easy of administration, and of course, budget. The main two options are:

  • the search module that ships with Drupal core
  • Search API (and related modules)

Of these two, Search API is by far superior, but it also requires the most resources because it offloads the search capabilities to another server (i.e. Apache Solr or Elasticsearch). For an a new startup, the technical and financial requirements are just not in the budget or for an average blog, these are just overkill and a waste of time and money. That leaves you with the core search option, which is what I want to cover in this post.

Under the hood

Before you can set up your site search, you need to understand how core search works. Internally, the core search all boils down to how many times a keyword is found in each piece of your content. That count is then given a weight, and possibly one or more multipliers such as keyword relevance, number of comments, etc. giving it an overall score. (More on multipliers more below.) When someone enters search keywords on your site, a database query is then run against those keywords and ordered by the overall score of the given keywords that have been indexed.

Configuration

Getting the optimal results from core search comes down to configuring it correctly for your use. You can edit the search indexing settings, logging, and search pages by going to Administration › Configuration › Search and metadata. Each plays a critical role in the search functionality.

Indexing Settings

Under the default search indexing settings, you will see a field with the minimum word length to be indexed and it's default value is set to three. I found that it is best to leave this setting at it's default. If you increase it, you could start eliminating true keywords and if you decrease it, you'll start bloating your indexes with words that aren't relevant in any context.

Search Pages

With Drupal 8, you can have multiple search pages to search different types of entities. By default, it comes with two search pages; content and users. Here, I will focus on the content search page.

Content Ranking Factors

The critical settings for search pages are in the content raking section of the search page edit form. Here is where you set the multipliers for keywords for a number of factors. By default, all of the multipliers are set to 0 meaning they are ignored completely.

There is no right or wrong setting for any of the options, only personal preference. The higher value for the multiplier that you select for each factor gives the searched keywords more influence in the results.

Example

To understand how to use the multipliers consider the following. Say that you run a local news website and you want a news article that was promoted to the front page to have slightly more influence over a commentary article about the same topic that would have appeared on page 3 of a traditional newspaper. But for both of these, keyword relevance has more value than anything. Both content pieces have roughly the same number of occurrences of any given keywords. So, for keyword relevance, you might have a multiplier of 8 – 10 (max.), and for content promoted to the front page, you might increase the multiplier to 2 or 3. This would give the news article a higher listing on the results page than the commentary.

Now, suppose that you set a multiplier value for the recently created to 7 and the commentary article was created three days after the news article. Now, the commentary article will appear before the original news article.

Cons of Using Core Search

While core search is fairly easy to set up, administer, and use, it is far from ideal. You can not, without additional modules or custom code, define items that are not to be searched. Core search will index every piece of content on your website. Items that a user does not normally have permission to view will show up in the search results listing and link to the content page itself. The user will then get a page showing them a message they aren't authorized to access that content. To me, that's a bad user experience.

Conclusion

Overall, for a small business startup or an average blog website, core search is capable of providing the end user with fairly relevant results when searching if the content was created using strong keywords and the site owner views search criteria the same as his/her audience and sets the multipliers correctly. For larger high traffic websites where search capabilities need to be more flexible and items such as PDF or Microsoft Office documents attachments to content must also be searched, you will be better served in researching the Search API and companion modules.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.