既存のApache Solrのモジュールに問題があるようです。
私は回避策を考え出しました。将来的にこのスレッドにつまずく人は、より良い解決策を見つけたら投稿できます。
/**
* Implements hook_comment_delete().
*/
function yourmodulename_comment_delete($comment) {
// While deleting a comment, the apache solr comment count field,
// "is_comment_count" does not get updated unlike comment addition. The reason
// is while deletion the apache solr module updates the comment entity but not
// the corresponding node entity. Hence the node needs to be explicitely re-
// indexed. Since I am already using the "apachesolr_realtime" module , the
// "apachesolr_realtime_index_now" function has been used for this purpose.
// Get the parent node of which this comment belongs to.
$parent_entity = entity_load('node', array($comment->nid), array(), TRUE);
$parent_entity = $parent_entity[key($parent_entity)];
// When the hook_comment_delete function is invoked, the comment count is
// still not reduced. Hence, drupal_register_shutdown_function has been used so that
// the call to apachesolr_realtime_index_now is invoked only after the comment
// and it's corresponding count has been uodated.
drupal_register_shutdown_function('apachesolr_realtime_index_now', $parent_entity, 'node');
}
おかげ
各ノードDrupalのノードへとのコメントの数を、対応するビューが表示された結果、それは右ですか? – EricLavault
Solrで直接見ることができますか?はいの場合は、コミットを発行して、それが消えるかどうか確認してください。それが消えると、Drupalモジュールはコミットコマンドを忘れてしまいます。 –
@ericLavault:そうです。私は前に述べたようにapacheソルバービューと 'is_comment_count'ソルフィールドを使用して、その特定のdrupalノードのカウントを表示しています。 @AlexandreRafalovitch:はい、solrを直接チェックインしていますが、それ自体でコメントを削除した後では表示されません。そのため、ビューは正しいカウントを順番に引き出すわけではありません。あなたはコミットコマンドが意味することと同じものを実装する方法を詳しく教えてください。私はこのSolr drupalモジュールが比較的新しいです。 –