How to Use Drupal’s Search Module

search

A lot of things are simple in Drupal … once you know how.

The Search module is a perfect example of something that is initially confusing to set up, but simple once you know how to do it correctly.

This week we had several questions from our members about the Search module, so we wrote this tutorial to help them out.

There are several confusing elements to the Search module. Let’s address them one-by-one:

Confusion #1: Indexing isn’t instant

When you write a new content item for your Drupal site, it appears on your site:

media_1366985171978.png

However, when you search for the content, it can’t be found:

media_1366985198133.png

So here’s the first point of confusion: your content will not be indexed instantly after it has been added to the site.

Confusion #2: How to re-index the site

After users have tried and failed to find their new content, they often head to Configuration > Search settings. This is a logical step. Even when you visit this page, the information seems helpful.

In the image below, I see that there is 1 new item that needs to be indexed:

media_1366985223543.png

However, if you click the “Re-index site” button, it won’t produce the result you helped for.

media_1366985303815.png

So that’s the second point of confusion: Configuration > Search settings isn’t very helpful.

The correct way to get your site’s content indexed is to go to Configuration > Cron.

Drupal’s Search module requires a cron job to run correctly.

Inside Configuration > Cron, click on the “Run cron” button.

media_1366985431664.png
media_1366985361087.png

Now the Search module will successfully index your new content:

Confusion #3: When cron runs

On the Configuration > Cron screen, you can tell your site to run cron regularly. This should index your content automatically, but it’s not always easy to tell when this will happen.

The cron job will be triggered by the first users who visits your site after the time period is up. So, even if you have the cron set to run every 3 hours. it won’t run until the next visitor arrives.

This is one reason why people can become confused by using the Search module on development sites where vistiors are rare.

media_1366985541836.png

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
RdeBoer
RdeBoer
11 years ago

Great little article for newbies to avoid the pitfalls when configuring Search in Drupal.

Who hasn’t at least once pressed the “Re-index site” button only to find that afterwords you’re left with less than what you started with!

Well done!

Diego Mauricio Poveda Carreño
Diego Mauricio Poveda Carreño
7 years ago

good day

First of all I give you a big greeting and congratulations for this post on the other hand I want to ask you for help since I am working with the search module and I need to direct it to a dress that designs to show the results, I have looked for documentation and I do not have a result so easy.

I hope you can help me.

THANK YOU VERY MUCH

daniel-pickering
7 years ago

Hi Diego
What stage did you get to before you noticed the issue ?

Diego Mauricio Poveda Carreño
Diego Mauricio Poveda Carreño
7 years ago

good day.

Well, I tell you to install the module, do the configuration, design the dress to show the results, but I still can not identify how this module works, and manage to direct the results to my view.
I hope to be clear with my description
2016-12-06 6:06 GMT-05:00 Disqus :

4
0
Would love your thoughts, please comment.x
()
x