Cool stuff about Drupal search I learned from Robert Douglass

I've been a Robert Douglass fan for a long time. My first Drupal book was penned by Robert. I learned from him then and continue to pick up bits of wisdom from his ongoing stream of articles and presentations.

Here's a list of ways to improve Drupal search that I've compiled from things I've learned from Robert over the past two years:

Install the Porter-Stemmer Module [1]
From the project page: The Porter-Stemmer module reduces each word in the index to its basic root or stem (e.g. 'blogging' to 'blog') so that variations on a word ('blogs', 'blogger', 'blogging', 'blog') are considered equivalent when searching. This generally results in more relevant results.

Adjust the Content Ranking Weights [2]
Out of the box, results on Drupal's search results page are equally weighted. You can change what's important to you (and your users) by tweaking the weights found at bottom of the /admin/settings/search/ page.

The default settings: Where I like to set them: YMMV
Factor Weight Factor Weight
Keyword relevance 5 Keyword relevance 7
Recently Posted 5 Recently Posted 5
Number of comments 5 Number of comments 4
Number of views 5 Number of views 6

Get to Know Views Fast Search [3]
Use Views Fast Search to build blindingly fast, incredibly flexible search pages. In addition to being a really fast search replacement, Fast Search allows you to build user-friendly and highly functional search forms. On Symantec's "Juice" site, we use this form to drive the content finder in the "Juice Cellar".

Use H1 Tags Sparingly [4]
When you mark up a story (using HTML) on a Drupal site, the indexing engine reads your markup and applies a "multiplier" (a measure of importance) to each word. When a user does a search, words you've marked as important play a greater role in whether or not a story shows up high in the search results. Here's a list of tags and their multipliers.

  • h1 => 25
  • h2 -> 18
  • h3 -> 15
  • h4 -> 12
  • h5 -> 9
  • h6 -> 6
  • u -> 3
  • b -> 3
  • i -> 3
  • strong -> 3
  • em -> 3
  • a -> 10

Each time you wrap a heading in <h1> tags, you're telling the search indexer that each word in the heading is 25 times more important than the normal words in your story. Note to self, "engage brain before attempting markup".

Drupal already wraps the page title in h1 tags (in most of the themes I'm aware of). Maybe one phrase holding very important words is enough -- use h1 tags with moderation.

Use Search 404 Module to Help the Lost Find Their Way [5]
At the risk of looking (even more) like a stalker, here's one more tip. I was reading a Planet Drupal post that linked to Robert's site. When I attempted to follow the link, I ran into a 404 page but this one was fairly cool (as far as 404 pages go). It actually used words from the URL to perform a search and help me find the missing page by displaying a list of search results instead of the less-than-helpful "404 page not found".

When I emailed Robert to see what kind of custom magic he was working, he responded with "Search 404 Module".

+++++++++++++++++++++++++

[1] From the 2007 OSCMS Summit talk, "Drupal Search: Core API; CCK and Views".

[2] Drupal's search module and scoring factors

[3] Custom search forms with Views and Fastsearch

[4] Lullabot Training, Portland

[5] robshouse.net

Comments

Nice list =)

One more that I hope you'll add in the future:

The new ApacheSolr search module is a great beginning to a wonderful relationship between Drupal and Solr. If you watch the video of my ApacheSolr FOSDEM presentation, you'll note that I repeatedly call for help. The goodies that Solr offers are worth it, now I just need the help of a bunch of smart Drupal developers to help whip it into shape and make it shine.

Nice Job

Great list, Kevin. I did some stuff with views_fastsearch module last night and was amazed. It saved me! I will definitely look through this later this afternoon. Good stuff here. I should pick-up that book.

See you at the next meet-up.

Andrew

Live Search

I've given in to the temptation of doing some shameless advertising. Live Search integrates nicely with Drupal search should anyone want any kind of hip, Ajaxy live search on their site.

Thanks!

Thanks for this -- I had some notes from a presentation Rob gave that I promptly lost, and I think you covered a lot of what I was trying to remember... saved by the internet! ;-)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Glossary terms will be automatically marked with links to their descriptions

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.