Escaping special characters in Jira JQL Search

Mathieu Yargeau October 2, 2015

I seem to have the same issue as this person: https://answers.atlassian.com/questions/47338 (I'm using the advanced search however, and I'm planning the URL encode the JQL to use the REST API)

 

I am trying to find specific issues which the summary begins with "[QC TASK]".

I tried the following, which works, but also finds other issues I don't want, like one having the summary "have the QC tasks displayed"

summary~"QC TASK" and status="in progress"

 

This returns the exact same thing:

summary~"\\[QC TASK\\]" and status="in progress"

 

And if I don't escape the '[', it results a lot of things that I don't want.

 

How do I make this work properly? Another solution would be to use an operator "starts with" instead of "contains", does that exist? Or maybe even make the search case sensitive.

3 answers

3 votes
Gregory Schwedock January 27, 2018

It's a bug. Vote and watch it here: JQL queries with special characters [ ] returns incorrect results

 

Issue has been going on since 2011, this issue is "resolved" but Atlassian has a "\\[funny\\]" definition of resolved: https://jira.atlassian.com/browse/JRASERVER-25092

Gregory Schwedock January 27, 2018

and it's because JQL implements Apache's Lucene search which strips all non-word characters.

 

you can use plugins to solve it looks like:

free:

https://marketplace.atlassian.com/plugins/proficient.developer.plugins.jira.power-jql/server/overview

 

or paid: "script runner" plugin.

Joe Chlimoun March 12, 2019

Power JQL is no longer free, but similar functionality can be achieved with the free SQL+JQL plugin.

Like Christel likes this
3 votes
JamieA
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.
October 4, 2015

You can't do this in JQL.

ScriptRunner has issueFieldMatch, which you can use like this:

issueFunction in issueFieldMatch("", summary, "\\[QC TASK\\].*")

The first parameter is a JQL function to narrow down the issues where the regex will be run on the summary field.

0 votes
GabrielleJ
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.
October 2, 2015

JQL does not have something like that "startsWith". It's documented in their site on what and what you cannot use:

https://confluence.atlassian.com/jira/advanced-searching-179442050.html#id-__JQLTextFields-Summary

There are reserved characters as well

https://confluence.atlassian.com/jira/advanced-searching-functions-338363497.html#AdvancedSearchingFunctions-characters

Mathieu Yargeau October 2, 2015

Yes, this is the article I read for the reserved characters. I did exactly the same thing as in the example they gave, escaping the '[' and ']', but it still finds the other Jira ticket that doesn't match.

GabrielleJ
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.
October 2, 2015

I must have been confused by this {quote} And if I don't escape the '[', it results a lot of things that I don't want.{quote}

Suggest an answer

Log in or Sign up to answer