CONTAINS (~) does not seem to work when searching description?

I'm trying to use the ~ operator as per https://confluence.atlassian.com/jira/performing-text-searches-185729616.html

The description in my test issue is one line like this:

     It contains ABC=someWord_and_these_TOKENS and other text too.

 Now if I search with:

  project = "GMX" AND Description ~ "ABC=someWord_and_these_TOKEN"

it finds my test issue. On the other hand, these do not work:

  project = "GMX" AND Description ~ "ABC=someWord_and_these_TOKE"
  project = "GMX" AND Description ~ "ABC=someWord_and_these_TOKE?" 
  project = "GMX" AND Description ~ "ABC=someWord_and_these_TOKE*"
  project = "GMX" AND Description ~ "ABC=someWord_and_t?ese_TOKENS"

 This seems baffling - these are pretty close to the examples in the documentation.

Version: Atlassian JIRA Project Management Software (v7.1.2#71006-sha1:8e7e309)

4 answers

1 accepted

Hi Dan,

JIRA search will remove the underscore (_) character and will treat it as a whitespace https://jira.atlassian.com/browse/JRA-32441 https://jira.atlassian.com/browse/JRA-5567 so when you're searching for

"ABC=someWord_and_these_TOKE" for example it will try to find an issue that contains all the words - ABC=someWord, and, these, TOKE and will probably actually ignore and  word https://confluence.atlassian.com/jira/performing-text-searches-185729616.html#PerformingTextSearches-Reservedwords 

You can search for an exact phrase you need to quote the phrase like that "\"ABC=someWord_and_these_TOKENS\""

Also in some cases and might be considered as a boolean operator https://confluence.atlassian.com/jira/performing-text-searches-185729616.html#PerformingTextSearches-Booleanoperators

So it's a bit complicated as the text you're searching is actually split into phrases and a lot of rules apply. 

Would you tell us what's the exact use case i.e. when having this phrase or similar "ABC=someWord_and_these_TOKENS and other text too" - what do you want to search for , so we can figure out the correct way to do that via JQL?

As a workaround you may consider using the Script Runner JQL function issuefieldmatch  which allows you to match field value using regular expression and I think this will be much more reliable than the JIRA fuzzy search in this case where you've got special character to match.

https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html#_issuefieldmatch

Thanks for an excellent explanation - looks like the underscores are to blame. My use case is in fact that I have to match the exact word (with underscores) - it is the formal name of a test - so the exact phrase matching looks like a solution even if the syntax is a bit clunky.

I'll take a look at issuefieldmatch too.

Hmm. I removed the and part of the token, to avoid confusion (and my use case will not have any ands in it). Also reduced to searching for the part after the =. However, the problem persists even if I quote the phrase, i.e.:

"\"someWord_these_TOKENS\""

 ..matches, whereas any partial or wild-carded version does not match. So I think the fuzzy search is just not going to work.

Anything particular in them? They look like the standard information about searches, can't find anything that indicates that there should be something non-standard about my syntax?

Hi!
I did ran in the same topic with the requirement to search for an text containing several underscores.

I also tried the descripted escaping "\"someWord_these_TOKENS\"" with no result.

Are there any updates, additional infos available how to overcome this problem?

any help is appreciated

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,338 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot