How to display comment count for issues in JIRA filters

I need to build a filter in JIRA that displays how many comments each issue has and sorts them accordingly. I attempted using this query:

project = "testProject" AND created >= 2012-05-01 AND created < 2012-07-01 ORDER BY comment.count

I’m working with JIRA version 4.2. What’s the correct approach to achieve this? Is there a specific function or field I should be using to get the comment totals? Any help would be appreciated.

no way to count comments in v4.2 using JQL - so frustrating! i’ve heard of users utilizing ScriptRunner to make a custom field for tracking comments, then sorting by it. it takes some extra effort, but if it’s crucial, it can be a solution.

JIRA 4.2 doesn’t support sorting by comment count in JQL queries. The comment.count field just isn’t available in that version. I’ve worked around this by exporting filter results to Excel and using a custom field to track comments when I need to. You could also create a dashboard gadget showing issues with recent comments, but it won’t give you the exact count sorting you’re after. If you really need comment count functionality, you’ll have to upgrade JIRA or find a third-party plugin that extends JQL.

JQL in version 4.2 lacks a direct method to sort by comment count. A workaround is to utilize the REST API: send a request to /rest/api/2/search with your filter, and then retrieve the comment counts from each issue’s fields in your application. Alternatively, some teams have implemented a custom number field that can be updated with comment totals through scheduled scripts, allowing for straightforward sorting in your filters.