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)

5 answers

1 accepted

0 votes
Accepted answer

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

Also having a lot of frustrations with searching issues that have underscores in issue description. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,949 views 19 22
Read article

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