How to search for labels with a wildcard?

Nica Huestegge April 8, 2013

Hi!

Can anyone tell me how I can search for all labels containing a certain word?

I've tried:

labels = "word*" brings no result

labels ~ "word*" brings massage "is not supported by the field labels"

I want to be able to build filters for groups of labels, i.e. "linux-*", "macos* etc.

Thanks,

Nica

10 answers

11 votes
Mark Symons
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 20, 2013

Try the "issueFieldExactMatch" JQL Function from Script Runner plugin.

issueFieldExactMatch (subquery, fieldname, regexp)

Here's an example for searching labels:

issueFunction in issueFieldMatch("reporter = fred", "labels", "ie[8|9]")

This will locate my labels "ie8" and "ie9" but not give matches against "ie7" or "review" (etc)

Ondrej Matejka May 19, 2014

Hi Mark,

can this issueFunction be used for identifying issues with labels starting with a specifies string "c/"?

I am using query

issueFunction in issueFieldMatch("", labels, "c/.*")

but I also get results where labels dont start with but only include the required string (e.g. "asc/something")

Can you please advise?

Thanks,

Ondrej

Like Michael Thompson likes this
Mark_Booth
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.
October 22, 2014

@Ondrej, you might be able to use a regex "^" start of line anchor, i.e. "^c/.*" to do what you want. Sadly this only really works if you have only one label, or you c/ label is the first label.

J B December 28, 2015

TLDR: Try '\\bc/.*' Use 'word boundaries' rather than 'start of line'. Following up on Mark's comment, the workaround is to use the word boundary pattern rather than the 'start of line/input' pattern. The labels field is treated as a string containing the list's elements, which is why the start of line pattern isn't matching what you'd hope. See here for more useful patterns: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

Philip Schlesinger June 28, 2016

Thank you for this!

7 votes
Laura Franco August 21, 2013

Yes, that has happened to me twice in the past 2 or 3 months. I like JIRA and the plug-in approach. What I don't like is that the cost of all the plugins is starting to approach the cost of JIRA itself.

2 votes
efavreau September 19, 2018

My solution is derivative of Mark's above, and is the only solution I could find. However, in order to implement this, I have modified this so it can be understood by people who do not understand regular expressions. This exactly solves the question asked.

issueFunction in issueFieldMatch("project = foo", labels, "(matchonexactlythis)")

First part: I am performing a JQL query for my entire project (in this example, the project is named foo).

Second part: I am searching for labels

Third part: I am using a regular expression that reads to look for what is between the parenthesis, regardless of anything else.

This will find labels named matchonexactlythis, ionlywantomatchonexactlythis, and matchonexactlythisplease, within the foo project.

 To use this JQL query, copy and paste it in. Update the first part with as generic or specific a query as you want. Update the third part, between the parenthesis with the word you are searching for.

Matt October 2, 2019

Hi, how could I use this query to search in all projects?  Something like:

"project = *"

I tried removing the

"project = foo"  

from the query to see if that would just search all projects for the specified labels, but then read that "issueFieldMatch" requires 3 parameters:

issueFieldMatch (subquery, fieldname, regexp)

I haven't been able to find how to set the "subquery" parameter to equal ALL projects.

Thanks. 

Venkatesh Prasad October 3, 2019

Hi Matt,

Solution to this is a simple workaround.

issueFieldMatch requires subquery in its first arguement. So, you can build a filter called all_project. Use the condition as 'project is not EMPTY' while building the filter as this will list all the projects. Then use that filter inside the issueFieldMatch function. Something like this

issueFieldMatch ("filter='all_project'", labels, "(label)")

Matt October 3, 2019

Thanks for the tip.  I created a new filter "all_projects" with "project is not EMPTY" and used that for the subquery parameter in the function, but when I run the new query, it doesn't return any results.  Here is the new query:

issueFunction in issueFieldMatch("filter='all_projects'", labels, "(foo)")

 

0 votes
efavreau March 24, 2020

                                                        

0 votes
Diane Gage March 24, 2020

So how would you filter on a label NOT matching using wild card? 

for ex:

project = CAT AND status not in (Cancelled, Canceled, Done) AND labels is not  DOG_Sprint_1, DOG_Sprint_2, DOG_Sprint_3, etc?

I want to just be able to say DOG_Sprint_ and not have to include each one in the search as the search syntax will be huge!

Thanks

Dee

efavreau March 24, 2020

@Diane GageGive this a shot. Keep in mind, this will only exclude this exact partial string.

issueFunction in issueFieldMatch("project = CAT", labels, "^((?!DOG_Sprint_).)*$") AND status not in (Cancelled, Done)

0 votes
Alexandr Pustovit November 2, 2015

It's possible to search for labels using wildcards in JIRA only with addons, please give a try to following one Advanced Labels Search Plugin for Jira

0 votes
Laura Franco August 21, 2013

this is great to know! i just got this same question from my users and here is the answer posted only 9 hrs ago.

Mark Symons
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 21, 2013

I'm glad the answer was useful. Just be aware that the "Scripted JQL Functions" module in Script Runner may go commercial at some point.

0 votes
Phil Shapiro May 15, 2013

I could really use this too! I just assumed I could use wildcards on labels but was disappointed to find it didn't work. I guess I can create an 'or' query that matches all the known label forms that the regex would match. I'll have to update it whenever a new label is created, but it's better than nothing...

0 votes
Simon Davison April 30, 2013

I could really use wirdcards too and the above suggestion didn't help me either. I've been using labels (tags) on other sites like Delicious and Flickr for many years and have developed a basic hierarchy to my tags. E.g. Actor:PM, Actor:Client, Value:Client_Engagement etc. I want to be able to search for all labels that start "X:" but without a wildcard that seems impossible in Jira.

Nica Huestegge May 15, 2013

I've started helping myself with custom fields instead, but that can't be the answer...

0 votes
Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 8, 2013

Hi Nica,

You can see how to use wild cards in JIRA in this page, however, I believe this will only work if the JIRA Indexing Language is set to other due to word stemming. You can see more about this in this other thread. If possible, try to set the indexing language to 'Other' in the General Configuration and re-index JIRA. Then, try to use wildcards again.

I hope this helps! :)

Cheers,
Matheus Fernandes

Nica Huestegge April 10, 2013

It took me some time to try this, because I had to re-index which I can only do outside of office hours...

But: nothing. I switched the indexing language to other and re-indexed. The results of my search are the same as described above.

Tim Black June 15, 2019

@Matheus Fernandes your link is broken. I think the page is now  titled "Search Syntax for Text Fields"?

https://confluence.atlassian.com/jiracoreserver080/search-syntax-for-text-fields-967898353.html

Suggest an answer

Log in or Sign up to answer