I was going through one of my projects and I came to know that how simple it is to insert additional information into your site's search indexes using hook_nodeapi. A comprehensive details about hook_nodeapi can be found here.
Following are the steps involved to make this happen:
- Create a module that implements hook_nodeapi, lets say example_nodeapi()
function example_nodeapi($node, $op) {
// Function definition here
}
- Add logic for node operation "update index" in hook_nodeapi function
if ($op == 'update index') {
$keywords = array();
// Implement logic to parse $node->body to get desired keywords and
// add one by one in $keywords array.
if (isset($keywords)) {
return implode(' ', $keywords);
}
}
- Full hook_nodeapi implementation for "update index" operation on $node will look like
function example_nodeapi($node, $op) {
// Function definition hereif ($op == 'update index') {
$keywords = array();
// Implement logic to parse $node->body to get desired keywords and
// add one by one in $keywords array.
if (isset($keywords)) {
return implode(' ', $keywords);
}
}
}