Comment statistics for node search rankings should aggregate all comment fields

Created on 20 August 2014, almost 10 years ago
Updated 9 November 2023, 7 months ago

Problem/Motivation

In CommentStatistics::getRankingInfo(), the search ranking for comment count is based on the count for specifically the default 'comment' field for nodes.

But now admins can add different comment fields to node types. So we should really be aggregating the count over all fields.

Steps to reproduce

Proposed resolution

Here's the current code:

'join' => [
  'type' => 'LEFT',
  'table' => 'comment_entity_statistics',
  'alias' => 'ces',
  // Default to comment field as this is the most common use case for
  // nodes.
  'on' => "ces.entity_id = i.sid AND ces.entity_type = 'node' AND ces.field_name = 'comment'",
],
...
'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * (ROUND(:comment_scale, 4)))',

What needs to happen is that in the join, we wouldn't restrict to ces.field_name = 'comment', and in the score, we would do a SUM(ces.comment_count).

This would require some kind of a group by, which I don't think hook_ranking() supports right now.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
CommentΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jhodgdon Spokane, WA, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024