Last updated January 25, 2014. Created by aj045 on December 18, 2003.
Edited by ryan.macinnis, jhodgdon, LeeHunter, Damien Tournoud. Log in to edit this page.

The search module lets users search for specific content on your site. You can search both for users and for particular words. When you are on the "content" tab of Search, you will be able to search for words appearing in the default rendering of node content on your site, which would include the default rendering of any CCK fields, Location fields, Taxonomy, etc., as well as comments. When you are on the "users" tab of Search, you will be able to search the user names of registered users on your site, and if you have sufficient permissions, also their email addresses.

In Content search, if you enter more than one search term the search module will look for content that has all the terms you've entered. If instead you want either one term or another, join your terms with "or." If you're looking for an exact phrase, enclose it in quotation marks.

With Advanced Search you can also look for "any of these words" or "this phrase," or both, you can rule out words you don't want, and you can choose content types within which to confine your search.

You can enable the search module on the modules page (administer >> modules in Drupal 7; administer >> site building >> modules in earlier versions of Drupal).

Note that by default, content search only finds exact matches for the keywords in your content. You can install a contributed stemming or n-gram module to modify this behavior.

Indexing

Drupal's search engine indexes the text content of the nodes on your site. You can tweak the way it does this.

The search engine does its indexing at intervals you choose by setting "cron runs." Cron (which stands for chronograph) is not a part of Drupal. It's a scheduler that resides on your server and runs tasks (called "cron jobs") at intervals, which you specify. The jobs can run weekly, daily, hourly, or whatever you like.

What you want to do is schedule a "cron job" that has a browser on your server regularly visit your "cron page." For instance, if your site were www.example.com your cron page would be http://www.example.com/cron.php in Drupal 6 and earlier versions; in Drupal 7, you need to visit the Status Report to find the exact URL to use on your site for external runs of cron, because there is a suffix on the URL.

Whenever a visit to the cron URL occurs, the search engine will take the work of indexing. You need to set up those cron runs before your search engine will work.

For a modest personal site to which you post now and then, you might set up such a cron job to run once a day. For a more active site you'd likely want to run that job more often--perhaps every few hours or every hour.

With Linux or Unix you can schedule your cron jobs by setting up what's called a "crontab." (You might rely on helper programs like C-Panel to make setting up your cron jobs easier.)

For further guidance on cron you can see Drupal's handbook page configuring cron jobs (or, if your server is running Windows, configuring Windows cron jobs). Your hosting company may also help guide you.

On your settings page for Search (administer >> site configuration >> search settings in Drupal 6, or administer >> configuration >> search and metadata >> search settings in Drupal 7) you can limit how many items should be indexed in a single cron run. This can help keep your system from getting overloaded with work. (If you get a message that cron is timing out or PHP is running out of memory, lower the number of items to index per run.) You also have a few more search settings you can choose.

Reindexing content

Content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content.

Unlike content-related actions, actions related to the structure of your site do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the Search settings page (administer >> site configuration >> search settings in Drupal 6, or administer >> configuration >> search and metadata >> search settings in Drupal 7).

Accessing Search

If both the search module and the menu module are enabled, from the menus page (administer >> menus) you can enable on the Navigation Menu the item Search. The option to show this menu item may be disabled by default, but you can enable it. (And you can rename "Search" to whatever you wish.)

You can also place a link to Search among your site's primary and secondary links, or on any other menu as well. (Click "add menu item," and when you fill in the "path" field on the dialogue page just enter "search.")

On your blocks page (administer >> site building >> blocks in Drupal 6, and administer >> structure >> blocks in Drupal 7) there's also a Search form you can enable, and you can choose where you want it to display.

On your permissions page (administer >> user management >> permissions in Drupal 6, or People >> Permissions in Drupal 7) you can decide who can do searches and who can administer the search settings. By default, anonymous users cannot perform searches.

A technical note: To use the search module the database user needs the create temporary table permission. If you do not have it, ask your systems administrator to make sure it's granted to you.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Enhancements for the core search engine:
Porter-Stemmer: http://drupal.org/project/porterstemmer

*EDIT* 2008-07-30 at the time I find the partial search patch for Drupal 6.3 core search very valueable (http://drupal.org/node/103548#comment-880849)

/grn

I find the paragraph in the text in the handbook page above vague.

With a regular search, if you enter more than one search term the search module will look for content that has all the terms you've entered. If instead you want either one term or another, join your terms with "or." If you're looking for an exact phrase, enclose it in quotation marks.

I would suggest the following based on the text in the excellent article by CivicActions.com: http://civicactions.com/blog/search/part_2

Search Query Types

Search queries can be done in a variety of different ways. Drupal's search allows the user create very powerful search by merely adding a few key words or symbols.

AND Searches

To get results which match multiple words, simply type the words that you want to find. This is the default behavior of Drupal's search.

OR Searches

To search for data which may contain one of a few terms, but not necessarily all of the terms, you need an OR search. Use the keyword OR in between each search term: "dogs OR cats" or "dogs OR cats OR birds".

Notice that the keyword "OR" must be capitalized. If you use the lower case "or" instead, search module thinks that this is another word to search for, and since it is probably smaller than the search word length (the default is 3 characters), search module simply ignores it and does a "AND" search on the two words.

Exclusionary Searches

You can search for things that don't exist. For example, if you wanted to search pet stores which do not have chickens, you need an exclusionary search. Drupal allows you to do this using the minus "-" sign. For example "pet stores -chickens" finds all nodes with "pet" and "stores that do not also contain the words "chickens".

Hi, I just found out that, when searching for keywords that are contained in blocks text, no results are found.

For example, in my site I have a side bar block containing the list of products, that I display on each product image gallery.

When I look for words "veneziane per interno" which are contained in this block, no result is displayed.

Search works normally when I look for text contained in pages.

Can anyone help me?

Thank you

As far as I know, the search function searches node content. So, no, it won't find block content. You may need an external solution for this.

I have newest drupal 6, and right out of the box search can't find text in the title of a forum, unless the forum has at least one post in it that contains the key phrase. Check it out: http://animalnepal.org/drupal_hum id= tester , pw = tester but I guess as said, it just searches node content? huh? Cheers,
jigs

From www.phoenixstudios.com.np, A Small A/V Studio in Kathmandu Nepal

I have a similar issue. I wonder if it is something that can be changed in the Site Configuration/Search Settings?

Add the block content into the node, but hide this from the teaser / full display modes.
Add this content it to the search display modes
Using CCK Field Blocks or a related module, add the content to the block.

Note that this only works if the block is limited to the page that contains the node.


Alan Davison
Back roads somewhere in South America

Hi:

I just confirmed that my cron is working fine and my search_index table has keywords and relevancy values from a node I just added.

BUT, when I try to search using the search form on a site page for something I SEE in the search_table, I get 0 results. How can this be? And, how do I fix it?

For example, here's what I see in my phpmyadmin in search_index when I search for "gaida":

word sid type score
gaida 2 node 1

BUT, this is what I get when I search in the site itself: http://www.bigbearhorrorfilmfest.com/search/node/gaida

Thank you,
~Todd

Same problem here. Reindexing did not help neither. User permissions correctly set. See also this forum post

By default, the search does not pull up UNPUBLISHED content. Make sure your content is published, and you have re-indexed and run the cron task.

Do you have status on Drupal out-of-the-box searching?

it doesn't work.

I am also experiencing a similar problem. I have imported a number of images using the image module yet i cannot search for the images by name using the search module. I have reindexed the site and also done a number of cron runs yet nothing. Any idea what i could be doing wrong.

Is it possible to search only within a section of pages?

For example- if in "mysite.com/town1" only search "/town1" pages - "mysite.com/town2" and only search "/town2" pages and so on...

Titles are not searched, only content

The search doesnt seem to find words in the titles! How can I configure search to search in the title field and all of the fields?

Diana Castillo

I think this module can help you. Please try it. http://drupal.org/project/search_by_page

Doubt is the father of invention..... Hubmesh | download converter

How does one disable a wildcard search (Drupal 6 Search module). Or put another way - is it possible to prevent wildcard searches and deliver only what is searched for, or a "not found" message?
thanks

Hi guys,

OK so my company has a few outside contractors who operate within our building. Specifically, there is a gift shop, a cafe, and a souvenir photo booth. As they are not part of my company, they have their own websites that I do not manage. Occasionally, a visitor to our site will try to find information about one of these contractors via the search function. They do not appear in the search because they are separate from us and I have no nodes for these contractors. My question is, can I configure the search function to include these three websites?

I know a quick solution would be to create a quick node with links to the three of these contractors, but I think it would be better if the websites just appeared in the search queries. is there a module that can allow this? Can I configure search to find these specific three sites?

Thanks in advance guys!

jibarra76

Thanks for sharing such a great information. We really impressed with your information.

Contractors

Hi, i really need to do searches on my custom field content, is there any way to do this?
Thanks in advance, any help will be highly appreciate.

One sentence tut. Install, create a view "page view", add field filters and expose these, set the page path & menu item and save.


Alan Davison
Back roads somewhere in South America

Hi Alan D. thanks for your clear one sentence tut.:) it solved my problem.

Hi Alan,
I can't figure out how to make this thing work : I've done what you told me in the one sentence tut :) so now i can make more precise search on the custom fields of my custom type, but the problem is the AND/OR filter criteria logic. It's not working in case i do not insert data ( i.e. i have a Group1 filters all in OR logic , and if i do not insert any data in this Group1 than is FALSE => (Group1)AND(Group2)=FALSE ) ... If i use everywhere the OR than i get to much general results, if i use AND i get no results. What i'm missing here?

Thanks in advance for your time and your help.

On the site http://www.forniturealberghiere.tv/ I discovere today that the table search_index was eating so many searches that now it eached more of 200mb!
1) How I can get it into a strong diet? It's simplyenough to delete all reords of the table or bettr to take care about something else?
I have also checked that from this custom theme I can't hide the search box from blocks administration.
2) Is there a way to limit the log of searches or something like that?

I have a D7 website in 3 languages. When user searches for a term, the results are shown in the 3 languages. How can I set the search-module to show just the results in the active language?

Search sometimes returns one "Anonymous" user row, sometimes none, sometimes more than one.
Each Anonymous row links to the http://site/user/ url
I looked in phpmyadmin and I could find only 1 anonymous user, as expected.

Francis

When updating live site from local dev, search does not work even after reindexing and running cron until 100% indexed. I am stumped.

I've found the culprit in my case, is that we were using the Backup and Migrate module for ease of export/import data from local to live. By default, it was set to ignore 2 tables search_index and search_data. We now do not ignore these and everything is good.

I think this might be the problem I am having but as I actually had an instance where the original db was lost and I could not restore from it can anyone help me figure out how to resolve it?

Hi,

I have search enabled on a couple of production sites and although I have Chinese and English content on the sites (which are 100% indexed), I only receive search results for English searches.

Strangely, I also have a local install of Drupal which returns results in both languages so I'm wondering if it's something at the server level that could be causing this? I have Drupal installed on IIS6.

Has anyone experienced any similar issues or have any idea what the problem could be?

Many thanks,

Maureen.

I have a multilingual site using i18n. Searching a taxonomy term doesn't give the same result as searching using its translation, meaning that my taxonomy terms are not indexed the same way as its translation. Does anyone has a clue on how to resolve that ?