JQL query that handles text or issue id?

Mark Johnson
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!
March 22, 2012

Aloha,

We have an app thats integrated with Jira which allows users to search through their Jira tickets etc. We do this by submitting a web form, taking the parameter and generating a JQL query similar to:
summary ~ "Search Terms" OR description ~ "Search Terms" OR comment ~ "Search Terms"

I'd like to have the ability to also search by issue id - like FOO-1234 - so the user could just enter search text or an issue id etc in the same search box (like how Jira itself handes search in top right corner of app).

Problem is that the issuekey requires a specific format, otherwise it errors and does not perform a search - i.e.:

summary ~ "Search Terms" OR description ~ "Search Terms" OR comment ~ "Search Terms" OR issuekey = "Search Terms"
=> The issue key 'Search Terms' for field 'issuekey' is invalid.

I would think this is a common search approach - but cant find any documentation/answers on how to do this. Thanks in advance!

1 answer

1 accepted

0 votes
Answer accepted
Renjith Pillai
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 22, 2012

That I guess you should do a bit of checking before submitting the JQL from your app. If it matches a '[A-Z]*-\d+' pattern submit it as 'issuekey = ' else submit it as 'summary ~ <<>> OR description ~ <<>> OR comment ~ <<>>'. By behaviour the 'Quick Search' also does the same.

Mark Johnson
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!
March 22, 2012

Thanks Renjith - I ended up going with that approach. Wasn't sure if I missed something in the docs because this seems like a common use case. Also - instead of my original question above using summary, description etc, Im now using:
text ~ "Search Terms"

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events