Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to limit a JQL search to return one Issuetype.

Danno
Community Champion
August 4, 2020

This seems really simple and I think I have even done this before although it was probably the other way around where I was trying to find more than one issuetype. I'm working in Cloud. My search is this:

project in (EAM, MFG) AND "Applicable Project" = Gryphon19 OR labels in (Gryphon-19, Gryphon19, Strato-Radar) AND issuetype not in (Sub-task, Epic) AND status = Done ORDER BY key ASC, created DESC

Both this search and using issuetype = Task returns both Tasks and Sub-tasks but surprisingly not Epics which also exist.

Something I noticed with JQL this time that seems to make a difference in my results is the order of placement of the individual queries within the whole search function. I'm now wondering if there are guidelines for the order of operation.

2 answers

2 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
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.
August 4, 2020

It's down to the way the and and or operators work - I suspect your query is not joining the clauses in the way you think it is.  And is pretty obvious - X and Y and Z does what you think, but when used alongside an and, OR becomes tricky - X and (Y or Z) is not the same as (X and Y) or Z.

Try these to see how the OR is doing things differently to the way you think:

( project in (EAM, MFG) AND "Applicable Project" = Gryphon19 ) OR (labels in (Gryphon-19, Gryphon19, Strato-Radar) AND issuetype not in (Sub-task, Epic) AND status = Done ) ORDER BY key ASC, created DESC

( project in (EAM, MFG) AND "Applicable Project" = Gryphon19 ) OR (labels in (Gryphon-19, Gryphon19, Strato-Radar) ) AND issuetype not in (Sub-task, Epic) AND status = Done ORDER BY key ASC, created DESC

Danno
Community Champion
August 4, 2020

Nic, you are the man. I think I see now how the order of operation of the search is critical. Cast the widest net first, then limit the filter in order of item needed. And I never even thought about using nested parenthesis in my search function. I will do some testing and see what I get.

Nic Brough -Adaptavist-
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.
August 4, 2020

It is, and I can never remember how Or and And combine!.  Note that in my answer I completely dodged saying how they were interacting.

I cheat and always stick brackets around every combination, just so I can be sure I know what it is doing!

Danno
Community Champion
August 5, 2020

LOL, somehow Nic I find it hard to believe you have trouble with OR & AND given how often I see your posts here in the community.

I'm really an engineering technician and not a software guy by trade except for LabVIEW. I had Jira brought in by someone else based on the recommendation of someone who is no longer here, and then had a "Jira expert" (read intern) set up a bunch of stuff w/o following good practices that I now have to clean up and manage. It's been eye-opening, to say the least, but after going through some online training I have been able to get a reasonable handle on things. I now get to struggle alongside my old school VP with learning agile/lean management.

0 votes
Answer accepted
Mehmet A _Bloompeak_
Atlassian Partner
August 4, 2020

Hi @Danno ,

In your query the OR operator is not grouped so your search returns concatenation of below 2 sets

  1. project in (EAM, MFG) AND "Applicable Project" = Gryphon19 AND issuetype not in (Sub-task, Epic) AND status = Done
  2. labels in (Gryphon-19, Gryphon19, Strato-Radar)

You should put the OR into parenthesis as below.

project in (EAM, MFG) AND ("Applicable Project" = Gryphon19 OR labels in (Gryphon-19, Gryphon19, Strato-Radar)) AND issuetype not in (Sub-task, Epic) AND status = Done ORDER BY key ASC, created DESC
Danno
Community Champion
August 4, 2020

Hi Bloompeak,

Thanks for the confirmation of the use of parentheses. I had read Nic's reply and had started a reply to him which I didn't send because I went off to try some quick changes to my search and see what the results were. I got interrupted and started doing something else altogether and then had to reboot my laptop and lost my response.

Suffice it to say I read Nic's reply which gave me the biggest clue that order of operation was critical. Here is my corrected search:

project in (EAM, MFG) AND issuetype in standardissuetypes() AND status in (Done, Closed, Complete) AND ("Applicable Project" = Gryphon19 OR labels in (Gryphon-19, Gryphon19, Strato-Radar)) ORDER BY key DESC, created DESC

This is what finally got me the results I wanted w/o the extra subtasks and Epics mixed in. It became quite clear that I was reeling those issue types into my net first and I didn't realize that you can't exclude them once they are in there. Another problem was I was trying to find the right combination of search items to use given I was digging through two completely different projects (One Next-Gen and one Core Business Project) with people using all kinds of labels and statuses as well as items that are resolved vs. unresolved.

Thank you @Nic and @Mehmet A _Bloompeak_ for your help. I am still a real newbie with administering our entire Jira system which is a real WIld West show where we had multiple people creating their own way of doing things.

Consider it answered.

Like Mehmet A _Bloompeak_ likes this

Suggest an answer

Log in or Sign up to answer