1

I use drupal core search.

When I build node index, I found it contain its comments.

But I don't need them.

Does anyone have a good idea about node index without comment.

I found a similar question How to not index comments in search_index?

It said that have to hack the comment module.

Does anyone have a better way ?

0

Not sure about this but came across this post https://www.drupal.org/node/680992.

There is a hook called hook_node_update_index()

// Prevent indexing of comments if there are any roles that can search but
// not view comments.
$index_comments = TRUE;
foreach ($perms['search content'] as $rid) {
  if (!isset($perms['access comments'][$rid]) && ($rid <= DRUPAL_AUTHENTICATED_RID || !isset($perms['access comments'][DRUPAL_AUTHENTICATED_RID]))) {
    $index_comments = FALSE;
    break;
  }
}
  • thanks for your reply. But it doesn't help me. – Rylyn Jul 22 '14 at 6:26
  • @Rylyn What about using this code without the role/permission checks? – Andy Jul 22 '14 at 11:18
  • @Andy Thanks for your reply. I think I have found a solution. – Rylyn Jul 23 '14 at 1:53
0

Finally, I use this solution to slove problem:

  1. Install elysia module, disable search_cron

  2. Write a custom module with a hook_cron

  3. In hook_cron function, I use module_invoke_all('custom_update_index');, a custom hook.

  4. Then write a hook_custom_update_index function to do something node_update_index do. And here, I add my custom index condition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.