Forums

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

JQL filter: "get stuff" and labels not in (XXX) also filters "EMPTY"

Yokai-FTW February 3, 2023

I have a query that is something like this:

project in (X, Y) AND component in (A,B,C,...) AND labels not in ("stuff")

This filter returns less than expected.  It filters the things with label "stuff", but also filters things with label = "EMPTY"

We fixed by changing the label stuff to: (labels != "stuff" OR labels is EMPTY)

However, it doesn't make sense to me that things without a label need to be specifically selected since "EMPTY" should not equate to "not stuff".  

Am I missing something or is this a bug (or a feature)? 

2 answers

1 accepted

3 votes
Answer accepted
Mikael Sandberg
Community Champion
February 3, 2023

This is expected behavior. When you are searching on label != X it will only search on issues that have the labels set to something, and that is why you have to include labels is EMPTY as well. Same thing if you would have a search that excludes a component, you would then have to include the empty ones as well.

Yokai-FTW February 3, 2023

OK, expected maybe, but weird IMHO. Thanks!

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.
February 4, 2023

It's not weird, it's logical.  Computers are logical engines, you have to be precise with them.  Humans are not, we can make assumptions!

Like Mikael Sandberg likes this
Yokai-FTW February 4, 2023

We agree on the end of your statement, but not the beginning. Computers are not so much logical as logic engines that have actions programmed by humans based on requirements.  In this case, it's a database engine with a rudimentary programming language, JQL.

To illustrate my expectations, here's how I think of the problem: If I have a set of 10 marbles, some are swirled with the color blue, some red, and some just clear.  If I ask you to "please give me all the marbles that are not blue", I'd expect you to give me the clear and red marbles, not just the red marbles.  

However, I can also see how the programmer might have thought differently.  Perhaps their design grabs all the things with labels and then returns the ones without the label I don't want.  That might have been the requirement they worked to or it's a bug (I favor the latter).

Anyway, if I assume the former requirement, then it explains the results.   

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.
February 4, 2023

So how do you answer the question "please give me all the marbles that are not blue" when you have some marbles where you don't know what colour they might be?

Logically, you can not.  Humans assume, computers need clear rules.

Yokai-FTW February 4, 2023

There is no assumption being made.  The request is made on the database which has numerous, known records. The URL I'm using to access our Jira database provides the context of what records to query.

 If I make a simple JQL query such as: "labels in (BLUE, RED)", it selects all records in the database that match that have those labels.  It's only problematic when I ask "labels != BLUE" 

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.
February 4, 2023

But how can you tell that a marble that you can not see is of a certain colour?

Simple answer, you can not.

0 votes
Keith Robertson August 28, 2023

Instead of

labels != stuff

labels not in (stuff, the_void)

use

# Select ticket if missing the named label.
NOT (labels = stuff)

# Select ticket if missing ANY of the named labels.
NOT (labels = stuff AND labels = the_void)

# Select ticket only if missing ALL of the named labels.
NOT (labels in (stuff, the_void))

These avoid having to check whether labels IS EMPTY.

Note: labels != stuff excludes when labels IS EMPTY, but NOT (labels = stuff) includes it!

Scott Hajek
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!
January 10, 2025

I just tested it in my Jira instance, and `NOT (labels = stuff)` does actually exclude issues where labels is EMPTY. Seems like the only way is to do an OR, like `(labels!=stuff OR labels is EMPTY)`

Suggest an answer

Log in or Sign up to answer