Blog

JIRA Query Language (JQL) – the most flexible way to search in JIRA

18 Oct, 2016
Xebia Background Header Wave

Regardless of your role – whether you are a developer, tester, project manager or business analyst – it is always good to have a quick access to the specific data that you want to work with. Let’s find out more about the JIRA Query Language – a powerful tool which can help you improve your work efficiency.

Why to learn JQL:

  1. It makes your job more efficient.
  2. It gives you quicker access to the data you are looking for.
  3. It helps you find out what the status of the sprint/project is.
  4. It’s easy and intuitive.
  5. You simply need it!

How to find and apply Advanced Search:

  • Log into JIRA
  • Click Issues
  • Click Search for Issues
    search-for-issues
  • Click Advanced
    advanced

Now you are good to go and write JQL queries!
search-bar

Query – how to write them?

Queries are series of questions connected together so it gets more complex. The main function of a query is to obtain the desired data from the database.

Query has three basic parameters: field, operator and value, which can be linked with the selected keywords.

Fields are different types of fields in JIRA filters, such as priority, fixVersion, assignee.
Operators link the field with the value. Common operators include: equals (=), not equals (!=), less than (<) etc.
Value is the real data in the query, which usually is the data you are looking for.
Keyword is a specific word in the query, such as AND, OR etc.

Let’s start!

Let’s go through a few examples of queries that might be useful for you on a daily basis:

  • What are the issues from the JQLProjectExample project?

The query would look as below:
query1
The result of this search are all the issues raised in the project named ‘JQLProjectExample’.

  • What are the bugs from the ‘JQLProjectExample’ project?

The query would look like that:
project = JQLProjectExample AND type = Bug

The result of that query are all the issues from the ‘JQLProjectExample’, which are bugs.

  • Which of the production bugs assigned to ‘John Smith’ Developer have been reported by ‘Arvel Callahan’ (QA)?

Query:
project = JQLProjectExample AND type = BugPRD AND assignee = John Smith AND reporter = Arvel Callahan

  • Which issues are blocking or critical in Projects X, Y and Z?

Query:
priority in (Blocker, Critical) AND project in (ProjectX, ProjectY, ProjectZ)

Note, that the “in” keyword will include any item which matches any item in the list.

  • Which of the issues are not assigned to anyone among all the projects you have available in JIRA?

Query:
assignee is EMPTY

  • Which of the issues were already tested in the ‘Sprint1’ and are not in the ‘XYZ’ project

Query:
project != XYZ AND status = tested AND sprint = Sprint1

  • Which of the issues contain text ‘code’ in the title of the issue?

Query:
text ~ "code"

Functions

Functions give the user power to manage the JIRA issues in an easy way.

Below, couple of especially useful ones:

  • What are the issues that have been created during the current session in JIRA?

Query:
created > currentLogin()

 

  • What are the issues that have been created by the currently logged since the user’s previous session?

Query:
created > lastLogin()

  • What are the issues that are assigned to a sprint that has not yet been completed?

Query:
sprint in openSprints()

 

  • What are the issues that are not sub-tasks?

Query:
issuetype in standardIssueTypes()

  • What are the issues created since the start of the day?

Query:
created > startOfDay
The same rule applies to a month, week, and year.

Here you can find more functions.

Sorting

If the query produces many results, you might want them sorted (ordered) by a specified field. Thanks to this, you can analyze data (and, based on that, take proper actions) more easily.

What are the bugs in the ‘XYZ’ project, assigned to Peter James (developer), ordered by the highest priority?

project = XYZ AND assignee = Peter James AND type = Bug ORDER BY priority

Saving filtres

After mastering writing the queries, it is high time to save and collect your efforts.

Saving queries gives you a quick access to the data you need, saving plenty of time.

Let’s create a filter based on JQL:

  1. Once you have entered the query, click the ‘Save as’ button, which is located just above the field where you type.
    saving1
  2. Give it a name and click the ‘Submit’ button.
    submit
  3. Go back to the main page of JIRA. In the upper- right corner, there is a list of your saved filters.
    favourite
  4. Click the filter that you have saved and the issues will be filtered.
  5. It is possible to edit permissions and share the filters with your co-workers. To do so, click on the saved filter from the main JIRA site. Next to the filter’s name there is the ‘Details’ button. Click it and then click ‘Edit permissions’
    edit-permissions
  6. You will be transferred to the view where you can change the name of your filter, add description or share it with a group or project.
    current-filter

Happy querying!

Questions?

Get in touch with us to learn more about the subject and related solutions

Explore related posts