• user warning: Got error -1 from storage engine query: SELECT t.* FROM term_node r INNER JOIN term_data t ON r.tid = t.tid INNER JOIN vocabulary v ON t.vid = v.vid WHERE r.vid = 78 ORDER BY v.weight, t.weight, t.name in /home/content/q/a/n/qandeel/html/drupal/modules/taxonomy/taxonomy.module on line 632.
  • user warning: Got error 28 from storage engine query: SELECT t.tid, t.* FROM term_data t INNER JOIN term_node r ON r.tid = t.tid WHERE t.vid = 1 AND r.vid = 78 ORDER BY weight in /home/content/q/a/n/qandeel/html/drupal/modules/taxonomy/taxonomy.module on line 617.

Index additional information using node_api hook

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 here

    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);      
      }
    }
  }