How to search for issues by rank with JQL ?

Eric Longoria May 8, 2017

I would like to search my project for the top 3 ranked issues.  I thought about using something like "LIMIT", but it looks like JQL does not support that.  For example, if Jira did have LIMIT support, I would be able to use a query like the one below to find the top 3 ranked open bugs in my project:

 

project = "My Project" and resolution = unresolved and type = bug order by rank LIMIT 3

Is there another way to achieve this same result without LIMIT?  Does Jira store the "Rank" value in a field somewhere?  What is the mechanism that Jira uses to detemine and store Rank?  I'm thinking that if Jira stores this information in a field, I could then write JQL to search for rank within certain values.  For example, if Jira used a field named "Rank Number", I could write something like:

project = "My Project" and resolution = unresolved and type = bug and "Rank Number" >= 1 and "Rank Number" <= 3

 

Ultimately, what I'm trying to do is notify my coworkers when they have an open bug assigned to them that is ranked in the top 3.  I want to use JQL to find these issues, then have each of my coworkers set up a subscription so that they are emailed whenever the search yields any results.  I want to use a JQL query like the below to set up their subscriptions:

project = "My Project" and resolution = unresolved and type = bug and assignee = currentUser() and "Rank Number" >= 1 and "Rank Number" <= 3

Which field should I use in place of "Rank Number" in that query?

3 answers

1 vote
MattS
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.
May 8, 2017

To do this inside JIRA you'd need to have something that periodically runs the JQL and then clears old labels or fields, and then sets the labels or fields in the top 3 issues. Better to do it with a script that uses REST to run the JQL and then sends email

 

 

Eric Longoria May 8, 2017

Right, but what would be the JQL that you would use to find the top 3?  That's the part I'm having trouble with.

MattS
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.
May 8, 2017

You can't. You have to search, order by rank and then iterate

Eric Longoria May 8, 2017

Got it.  I think that's the heart of my question: "Is there a way for me to search for, and compare, the 'Rank' field using JQL?".  Looks like the answer to that question is "no".

Jon Widén September 27, 2022

This post points out that you can use the REST API with parameter maxresults  to limit the number of results. Maybe that can be useful in your case, if ORDER BY Rank can be combined with maxresults=3 in the REST query? Haven't tried it so I don't know if it would work. Just a thought. Do reach out and let us know if you try it.

0 votes
Maysarah Abu-Laban November 7, 2019

I have the same question, can we do something like this in JQL?

Rank > i0sjpq:zrtw ORDER BY rank
Chris DeMattio November 11, 2020

I got my search to work by using the "<" comparison rather than ">".   I also ordered by rank ASC.

0 votes
Nilanka Ipitawala May 8, 2017

Use the Rank field

Eric Longoria May 8, 2017

How do you compare that field though?  It looks like Jira assigns jibberish values to the field "Custom Field (Rank)".  For example, here are the values that I'm seeing assigned to that field:

  1. 1|ht69dm:ujn
  2. 1|ht69dm:ujo
  3. 1|ht69dm:ujp
  4. 1|ht69dm:ujpi
  5. 1|ht69dm:ujq
  6. 2|i0i20p:
  7. 2|i0io6n:
  8. 2|i0io6o:
  9. 2|i0io6p:

 

How do I compare those values if I'm looking for the top 3 ?

MattS
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.
May 9, 2017

Alphanumeric sort I believe

Like John Miller likes this

Suggest an answer

Log in or Sign up to answer