How do I do a case-sensitive search in Jira?

Jennifer November 26, 2019

Hi,

One of our users has entered an incorrect-cased label in Jira, which is causing havoc with the filters we use, and confusion on which label is correct.  I'd like to do a case-sensitive search so I can pull up the incorrect field and change all those labels to the correct one.  This way, we can delete the incorrect label so it's not used in future. 

Basically I need to know how to search on 'tech' so I get 'tech' results and not 'Tech' results.

Can this be done?

-Jen

4 answers

2 accepted

4 votes
Answer accepted
Payne
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.
November 26, 2019

If you happen to have the ScriptRunner app installed, you can do regex, and thus case-sensitive, searching, like this:

issueFunction in issueFieldMatch("labels is not empty",labels,"tech")

or, if you (or someone you work with) has access to the database, you can run the following query:

SELECT project.pkey,issuenum,label
FROM label
JOIN jiraissue on jiraissue.ID = label.issue
JOIN project on project.ID = jiraissue.project
where BINARY label = 'tech'
ORDER BY pkey,issuenum

Jennifer November 27, 2019

Ah! Finally I can say thank you, Payne!  Apparently the IE browser (our work default) won't let me reply - it only allows me to mark the answer as accepted.  Switching to Chrome opens up the reply field.

It looks like we don't have ScriptRunner installed, as the search didn't work for me, but I'll see if I can get a database person to try the second option you suggested.

Thanks again for your help, and for the quick reply!

-Jen.

SWAPNIL SRIVASTAV December 5, 2019

Hello @Payne ,

I need to use issueFieldExactMatch method in my JQL, but I need to perform case insensitive search.

Could you please help me with any regex for that

Best Regards,

Swapnil Srivastav

Payne
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.
December 5, 2019

You can use the (?i) directive, like this:

issueFunction in issueFieldMatch("labels is not empty",labels,"(?i)tech")

Like SWAPNIL SRIVASTAV likes this
SWAPNIL SRIVASTAV December 5, 2019

Hello @Payne ,

Thanks for your reply.

It works but, I it gives match, not exact match. If we search for "tech", it will give results as "Tech", "Technology", "TECHNO", "tech"

But I want exact match i.e if we search for "tech", it should give results as "tech", "Tech", "TECH".

Could you please help me with that.

Thanks and Regards,

Swapnil Srivastav

Payne
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.
December 6, 2019

\b denotes word boundary in regex, so you can surround a string with it to search for a whole word only. You'll need to use double backslashes in JQL, i.e.

issueFunction in issueFieldMatch("labels is not empty",labels,"(?i)\\btech\\b")

SWAPNIL SRIVASTAV December 8, 2019

Hello @Payne ,

issueFunction in issueFieldMatch("labels is not empty",labels,"(?i)\\btech\\b")

does not give any results.

Using

issueFunction in issueFieldMatch("labels is not empty",labels,"(?i)\\bbtech\\b")

gives results, but that does not give exact results either.

Thanks for the response.

Best Regards,

Swapnil Srivastav

Payne
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.
December 9, 2019

Hmm, I verfiy that it works exactly as expected for me. Another thought is that since you're performing a case-insensitive match, you don't need to use the regex capability offered by issueFieldMatch; just perform a normal search, like this:

labels = tech

SWAPNIL SRIVASTAV December 9, 2019

Hello @Payne ,

JQL:

issueFunction in issueFieldMatch("project = ABC and issuetype = "DE", "Summary", "^(?i)Test$")

and for groovy:

issueFunction in issueFieldMatch("project = ABC" and key != ${issue.key}", "Summary", "^(?i)${summary}\$")

works fine for me.

Thanks a lot for your response.

Thanks and Regards,

Swapnil Srivastav

martin_heinrich October 27, 2020

Narrow down the initial search as much as possible for best ScriptRunner performance. Especially, don't just go for "labels IS NOT EMPTY", but do the case-insensitive search here.

0 votes
Answer accepted
Robert Leachman March 5, 2024

The first answer will kill your system (first, find every ticket with any label, and then check for the target). Don't ask me how I know.

Try this instead, find case-insensitive and then from those find the lower-case:

issueFunction in issueFieldMatch("labels in (sphere)", labels, sphere) ORDER BY created DESC

 

0 votes
Fasakin Oluwaseye December 29, 2020

 

If you happen to have the ScriptRunner app installed, you can do regex.

0 votes
Payne
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.
December 6, 2019

Another note about using issueFieldMatch and some other ScriptRunner JQL functions - the first argument is a subquery; for performance reasons, make it as restricted as possible, so that the remainder of the function has fewer issues to scrutinize. For example, you may can limit the search to a particular project, date range, etc. like this:

issueFunction in issueFieldMatch("project = BR and created > startOfYear()",field,regex)

SWAPNIL SRIVASTAV December 8, 2019

Hello @Payne ,

Yes, I know the fact, Thanks anyways for informing.

Best Regards,

Swapnil Srivastav

Like Payne likes this
Fasakin Oluwaseye December 29, 2020

Go to jira app and upload your documents

Suggest an answer

Log in or Sign up to answer