Search for issues with comments by user and text

luca-pittino January 31, 2018

I'm searching for all Jira issues with comments written by a given user and containing some given text.

I'm already aware of how I can search for issues with comments by a given user, for example:

issueFunction in commented("by user@domain.com")

or, if looking for my comments,

issueFunction in commented("by currentUser()")

But I'd like to specifically filter by comments satisfying both conditions: author and content. How can I achieve this?

Queries like

issueFunction in commented("by user@domain.com") and comment ~ 'text'

of course don't satisfy my requirement.

Thanks in advance!

4 answers

4 votes
Ashkan Malekly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2020

Hi @luca-pittino  and @Björn_Schotte 

I had tried this jql and get my favorite result

Comment ~ "\"text\"" and issuefunction in commented (" by user@domain.com")
luca-pittino March 11, 2020

Hi @Ashkan Malekly, I guess your case was a lucky combination :)

Your suggestion is basically the last query I wrote in my question above, with the difference you're searching `"text"` (quotes included).

My problem is that I need to match isses having single comments satisfying both conditions A and B, but I can only get issues with some comment satisfying A and some other comment satisfying B.

Ashkan Malekly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2020

Hii @luca-pittino  

No in my code include ( \ ) this is important.

this is yours:          comment ~ 'text'

And this is mine :  comment ~ "\"text\""

Like Vera Dukic likes this
luca-pittino March 11, 2020

Sorry @Ashkan Malekly, I think I've been mislead by the fact that even using quotes I still got many results with comments not matching both conditions (false positives)..

Actually though, the amount of results with and without quotes is different (e.g. ~70 and ~120 respectively).

Maybe something related to Jira app version? I'm using Jira Server 7.1.4, maybe on later versions they did some improvements?

Ashkan Malekly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2020

@luca-pittino  could you tell me the username and comment? I think you miss somewhere in the code. I want to implement your username and comment in my code give you back and please put it in your search bar. Thanks 

Vera Dukic
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 13, 2020

Does anyone know if there is a way to display the comment text in the results?

Like Pavel Melik likes this
Pavel Melik
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 9, 2020

It is necessary to search for text in the comment of a specific user.  i can't find a solution to such a problem in JQL.

issueFunction in commented("by user") AND comment ~ 'text'
- not satisfied with the results.

 

I want to have something like (fantasizing):

comment ~ 'text' ("by user")    //OR//   issueFunction in commented("by user  / text ~ blabla ")

?)

Like eddyg likes this
1 vote
Vasiliou_ George November 1, 2023

This is exactly what I am looking for, but we're on the cloud version now and get an error.

The URL provided at the end gives a 401 error also; there is no help there either.

 

The "commented" JQL function provided by "Adaptavist Scriptrunner" for Jira Server works differently in Jira Cloud. Run it directly in "Enhanced Search" instead. See the documentation for more details: https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-jql-keywords-functions

luca-pittino November 2, 2023

I guess the expected doc page is https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-enhanced-search/jql-keywords.

But again I don't see a solution for the matter...

Jasmin Bateman November 2, 2023

In answer to both your queries:

We have a documentation page linked here dedicated to highlighting the differences in JQL syntax between ScriptRunner for Jira Server and ScriptRunner for Jira Cloud. 

For your search query, if you are trying to use the server syntax:

issueFunction in commented("by <insert user>")


then please replace this with the equivalent cloud syntax:

commentedBy = <insert user account ID>

To achieve the same output in ScriptRunner ES for Jira Cloud.

Please let me know if this solves your query issue.


Kind regards,

Jasmin

Vasiliou_ George November 2, 2023

I actually figured this out and tried it, but I got zero results.  The Example they provided on the page is 

commentedBy = 5f8eddaaf162650070bce0fb

No issues were found to match your search

 

If I use something similar:

Text ~5f8eddaaf162650070bce0fb

I get a ton of results. Some of the results are from comments I made, and some are with comments others made and tagged me. Either way, I do get results that prove the formula above is NOT working, oddly.  I would like to only filter by the comments I made and exclude the comments where I am tagged. I am still looking for a correct way to do this because the temporary solution I came up with has too many comments I have to view that are not what I need and just become noise.

Jasmin Bateman November 2, 2023

Please can I check a few things:

1. Have you replaced the user account ID, with your own user account ID? 

You can find your account ID via this URL: http://<your instance>.atlassian.net/people
and searching for yourself. The account ID will then appear at the end of the URL.

2. Are you performing the search within the ScriptRunner Enhanced Search application? 
You can find the application using the Apps dropdown menu:

Screenshot 2023-11-02 at 14.21.59.png
And insert your search query here:
Screenshot 2023-11-02 at 14.35.08.png


3. The search query for the scenario you have described would be:

commentedBy = <your account ID> 

This will only return issues that your account has commented on.

0 votes
Nicolas PR September 1, 2022

Hi,
it's complicate to manage some special chars for your condition  'comment ~' (escape with '\' or '\\' )

you have to escape the special chars ex: https://confluence.atlassian.com/jirasoftwareserver/search-syntax-for-text-fields-939938747.html#Searchsyntaxfortextfields-escapingSpecialcharacters

0 votes
Björn Schotte
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 16, 2018

Hi Luca,

I do have similar problems. Did you solve the issue?

luca-pittino May 17, 2018

Not with a query unfortunately, nor with Jira filters.
I guess a search with similar expressiveness is unsupported at the moment.

In my case I searched by text, as I got the fewest results, and then manually checked the text occurrences and saw who the comment author was.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events