- π¦πΊAustralia mstrelan
Updated issue summary to use standard template and updated code snippet to match what's currently in 11.x
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.
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.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Updated issue summary to use standard template and updated code snippet to match what's currently in 11.x