views:

482

answers:

3

Somebody has posted an hour ago or so a question that was about the drupal search engine and was about like this:

I know drupal should index anything that is returned by node_view() but this is not happening for my custom content. Also: are there better alternatives to Drupal built-in functionality?

As the question has been removed while I was answering, and didn't want to throw away 20 minutes of my life for nothing ;) I thought to re-create the question a second time. Hope this is fine by the rules of SO! :)

+2  A: 

The Drupal search engine is probably not the most celebrated feature of Drupal, but is fairly solid, sophisticated and reliable. There are plenty of modules that enhance or substitute it but - at least in my experience - there is not a commonly accepted "better way" to manage searching and indexing.

However, for very big and busy sites people prefer to use external tools altogether, like a google searchbox or even dedicated software or hardware, like solr / lucene or google search appliance (GSA).

The link I provided above - however - sorts the search-related modules by descending usage statistics, so you will find on the first page the one most commonly used. One that I personally like for English language sites is the porter-stemmer, which index words by their stem (eg: highness, highest and higher will all be returned as matches for the word "high").

That was for the general information on search and Drupal. As for your problem, there are a number of things you could check to track down your problem:

  1. Have your cron.php been executed lately? Indexing is done as part of the cron run, so - if you do not have a crontab set or if you haven't executed it by hand, your node will likely not been indexed yet.

  2. Are the settings correct? Settings for the search module are located at http://example.com/admin/settings/search : is your minimum word length sufficient for your needs (the default is 3 letters)?

  3. Has the 100% of the site being indexed? (You can check that from the setting page). If it is not, and running cron.php doesn't solve the matter, look further down.

  4. Does a re-index solve the problem? Especially if you inserted data by mean of SQL queries directly on the Drupal tables, chances are Drupal hasn't realised the content of the node has changed and therefore doesn't update the index.

  5. Is the node you are trying to find, visible? Search results about unpublished nodes or nodes that require higher-than-yours permissions to be viewed are not returned, AFAIK.

As for the "stuck indexing" that happened to me once as well. It turned out it was some PHP code within a node body that would trigger a PHP exception when the node was being indexed, and as a result the indexing process would halt and all the following nodes would not be indexed as well.

Hope this helps. Good luck!

mac
A: 

Haha, sorry about removing my post. The issue was merely that drush search index doesn't actually work. If you run it through cron it should work just fine.

If this doesn't help mac's answer seems extremely good and thorough. Search should find your nodes just fine if an anon user can see them.

Chuck Vose
No problem, then! Happy you solved by yourself! :)
mac
A: 

But how did you know what PHP was causing the indexer to get stuck? How do you check? My cron seems to run fine, but it's not indexing anything anymore. I started a "re-index" and so far "0% of the site has been indexed" after two cron runs!

Anyone have any ideas?

Chris