Adding author name to the Drupal search index
Awhile back, I wanted to add author names to the Drupal search index. After poking around a bit, I found that this was actually pretty easy. I created a new module called custom_helper and in it put the following function:
<?php //Adding author name to the search index function custom_helper_nodeapi($node, $op, $arg = 0) { switch ($op) { case 'update index': if ($node->uid) { return $user->name; } } ?>
One thing to keep in mind is that if you do this, then you will need to re-index all of your previously indexed nodes if you wanted them to be indexed by author name.


Custom_Helper...
Hello Julia,
Stumbled upon your site in a Google Search.
We want Drupal to include author names in it's search index.
Your code you posted is super helpful.
Just need you to fill in some gaps for me.
Do we need to create a fully functional module, with all the correct files, then upload and "turn on" or can we just upload a single module file with the code above?
We've never created a module before so any direction would be appreciated.
Nice site! Great info!
-Danny
Re: Custom_helper
Hi Danny,
Yep, you'll need to create a new module. It's really easy. Just create a .info file and then a .module file with the code I have. There are some great docs on creating Drupal modules available. Here's a nice resources:
http://drupal.org/node/231276
Feel free to contact me via the contact form if you run into problems.
Cheers,
Julia
Post new comment