📜 ⬆️ ⬇️

Search for tasks in JIRA (simple language). Part 2: Advanced Search

The structure of JQL queries without examples is difficult to understand for specialists not previously familiar with JIRA.

We have already told you about the fast and basic search. Now let's move on to the most powerful of the three methods — advanced search.

In this mode, you can specify criteria that cannot be specified in the other two previous modes (for example, sorting ORDER BY). But you have to master the creation of structured queries using JIRA Query Language (JQL).
')


To use the "advanced" search, go to the menu item Search -> Search for queries.

And if you are in the "basic" search mode, click the "Advanced" button.





1. Creating JQL Queries

The simplest JQL query consists of a field followed by an operator, and then one or more valid values ​​for this field. For example:

project = "YAT"

Such a request will help to find all the tasks of the YAT project. The “project” field is used here, the operator is equivalent to “=” and the valid value is “YAT”.

A more complex query might look like this:

project = "YAT" AND assignee = currentuser ()

So we will select all the tasks of the project "YAT" assigned to the current user
(that is, on you). The request contains: the logical operator “AND”, the field “assignee” for selecting tasks for the current user, the operator equivalent to “=” and the function “currentuser ()”, which returns the name of the current user of the system.

When creating a query in Advanced Search mode, JIRA displays a list of all possible operators for the query field.

JIRA also shows a list of available values ​​for the " AffectedVersion ", " FixVersion ", " Components ", custom fields of the " Version " format and drop-down lists.

When used in searching for fields in the User format, JIRA allows you to find the desired user by his last name.

You can use parentheses in complex JQL queries. For example, if you want to find all resolved tasks in the SysAdmin project, as well as all tasks (of any status, any project) currently assigned to the system administrator (admin), you can use parentheses to indicate the priority of logical operators in the query.

(project = SysAdmin AND status = resolved) OR assignee = admin

Attention!

JQL has reserved characters.
symbol+.,;?|*/%^$#@[]

If you want to use one of them in the request, you need to:
  1. select text that contains a special character, either with double quotes ("......"), or single characters ('......');
  2. if the search text contains one of the characters listed below, then a double backslashe ("\\") is always put in front of it.
    + - & |! () {} [] ^ ~ *? \:

Example:
summary ~ "\\ [example \\]"

Attention!
JIRA also has reserved words.

If one of the following words is mentioned in the search text, this text should be highlighted with either double quotes ("......") or single quotes ('......').

List of reserved words:
A"Abort", "access", "add", "after", "alias", "all", "alter", "and", "any", "as", "asc", "audit", "avg "
B“Before”, “begin”, “between”, “boolean”, “break”, “by”, “byte”
C“Catch”, “cf”, “char”, “character”, “check”, “checkpoint”, “collate”, “collation”, “column”, “commit”, “connect”, “continue”, “count” "," Create "," current "
D“Date”, “decimal”, “declare”, “decrement”, “default”, “defaults”, “define”, “delete”, “delimiter”, “desc”, “difference”, “distinct”, “divide” "," Do "," double "," drop "
E“Else”, “empty”, “encoding”, “end”, “equals”, “escape”, “exclusive”, “exec”, “execute”, “exists”, “explain”
F"False", "fetch", "file", "field", "first", "float", "for", "from", "function"
H"Having"
I“Identified”, “if”, “immediate”, “in”, “increment”, “index”, “initial”, “inner”, “inout”, “input”, “insert”, “int”, “integer "," Intersect "," intersection "," into "," is "," isempty "," isnull "
J"Join"
L"Last", "left", "less", "like", "limit", "lock", "long"
M"Max", "min", "minus", "mode", "modify", "modulo", "more", "multiply"
N“Next”, “noaudit”, “not”, “notin”, “nowait”, “null”, “number”
O“Object”, “of”, “on”, “option”, “or”, “order”, “outer”, “output”
P"Power", "previous", "prior", "privileges", "public"
R“Raise”, “raw”, “remainder”, “rename”, “resource”, “return”, “returns”, “revoke”, “right”, “row”, “rowid”, “rownum”, “rows "
S"Select", "session", "set", "share", "size", "sqrt", "start", "strict", "string", "subtract", "sum", "synonym"
T“Table”, “then”, “to”, “trans”, “transaction”, “trigger”, “true”
U"Uid", "union", "unique", "update", "user"
V"Validate", "values", "view"
W"When", "whenever", "where", "while", "with"


2. Using Templates for Text Search

Special characters can be used to define text search patterns. Consider a few examples:
SignScope and descriptionExample
?"?" used to replace a single character in a pattern.
For example, the spelling of the words “text” and “test” is different.
single character. To search for both options is enough
set pattern: te? t
summary ~ "te? t"
*"*" is used as a replacement in a text template.
zero or more characters. For example, to select text
"Windows", "Win95" or "WindowsNT" can be used
pattern: win *
To select the text "Win95" or "Windows95"
You can use the template: wi * 95
summary ~ "wi * 95"
~"~" can be used to set
fuzzy search patterns. In this case, the character "~"
substituted at the end of the desired word. For example,
to find a term spelling similar to "roam",
use the pattern: roam ~
As a result, the words “foam” or “roams” can be found.

summary ~ "prox ~"


3. JQL logical operators

OperatorDescriptionExample
ANDLogical operation "And", connecting two or more conditions. Used to clarify the conditions of selection.
project = "YAT" and status = "Open" - select all the tasks of the project "YAT"
in the status of "Open"
ORLogical operation "OR", connecting two or more conditions.
reporter = demo_1
or reporter = demo_2 - select all the tasks of the project, the author of which
is user demo_1
or user demo_2.
NOTTo reverse the result of a logical condition.not assignee = demo_1 -
select all tasks authored by
is not a user demo_1.
ORDER BYSort by.

By default, your own order will be used.
used for this field. You can override the sort direction -
ascending (“asc”) or descending (“desc”).
duedate = empty order by created -
select all tasks that have “Due date” fields,
sort the results of the selection by the “Created” field.

duedate = empty order by created, priority desc -
select all tasks that have “Due date” fields,
sort the results of the selection by the field “Created”
in its own order, then in the field «Priority» (Priority)
in descending order.

4. JQL comparison operators
OperatorDescriptionExample
=Equivalent.

Used to set
full compliance criterion.
reporter = demo_1
! =Not equal.

Used to set the search criteria
which unequivocally says that in the found
The task must not contain a specific field.
a certain value.
reporter! = demo_1

or you can use the record
NOT reporter = demo_1
>More than.

Used to create expressions
with fields of format "Version",
date-time format and numeric fields.
votes> 4
duedate> now ()
> =More or equal.

Used to create expressions
with fields of format "Version",
date-time format and numeric fields.
votes> = 4
duedate> = "2008/12/31"
created> = "-5d"
<Less than.

Used to create expressions
with fields of format "Version",
date-time format and numeric fields.
votes <4
duedate <now ()
<=Less or equal.

Used to create expressions
with fields of format "Version",
date-time format and numeric fields.
updated <= "-4w 2d"
INUsed to select tasks by availability
in a specific field of one of the values.

The set of value options is distinguished from two sides.
parentheses, options inside brackets
comma separated.
affectedVersion in ("3.14", "4.2")
reporter in (demo_1, demo_2)
or assignee in (demo_1, demo_2)
NOT INUsed to select tasks
which field does not contain
none of the listed values.

The set of value options is distinguished from two sides.
parentheses, options inside brackets
comma separated.
FixVersion not in (A, B, C, D)

or you can use the record
not FixVersion in (A, B, C, D)
~Contains.

Used exclusively for criteria
selection by text fields.
summary ~ win
summary ~ "issue collector"
! ~Does not contain.

Used exclusively for criteria
selection by text fields.
summary! ~ "issue collector"

or you can use the record
not summary ~ "issue collector"
ISThis operator can be used
only with EMPTY or NULL values.

Used to search for tasks, a specific field
which contains no values.
fixVersion is empty
IS NOTThis operator can be used
only with EMPTY or NULL values.

Used to search for tasks defined
which field is required.
affectedVersion is not empty
WassFor the selection of tasks, a specific field
which previously had the specified value.

Applicable exclusively to the fields:

  • Reporter (Author);
  • “Assignee” (Contractor);
  • "Fix Version" (Fixed in versions);
  • "Affected Version" (Appears in versions);
  • Priority;
  • “Status”;
  • “Resolution”.

The WAS operator can also have the following optional predicates:

  • AFTER "date"
  • BEFORE "date"
  • BY "username"
  • DURING ("date1", "date2")
  • ON "date"

status WAS "In Progress" - for the selection of tasks
ever been in the status of "In Progress".

status WAS "Resolved" BY demo_1 BEFORE "2011/02/02" -
for selection of tasks transferred to the “Resolved” status
by user demo_1 until the date of "2011/02/02".
WAS INFor the selection of tasks, a specific field
which previously contained one of the listed values.

Scope and predicates used for
WAS IN operator, the same as for the WAS operator.
status WAS IN ("Resolved", "In Progress")
BEFORE "2011/02/02" - for the selection of tasks transferred
in the status of “Resolved” or “In Progress” until the date of “2011/02/02”.
WAS NOT INTo select tasks that never
or until a certain moment, contained in a certain
field none of the listed values.

The scope and predicates used for the WAS NOT IN operator,
the same as for the WAS operator.
status WAS NOT IN ("Resolved", "In Progress")
BEFORE "2011/02/02" - for the selection of tasks not previously located
in the “Resolved” and “In Progress” statuses
until the date “2011/02/02”.
WAS NOTTo select tasks that never
or until a certain moment, contained in a certain
setpoint field

The scope and predicates used for the WAS NOT operator,
the same as for the WAS operator.
status WAS NOT "In Progress"
BEFORE "2011/02/02" - for the selection of tasks not previously located
In the status of "In Progress" to the date "2011/02/02."
CHANGEDFor the selection of tasks whose field has been changed.

Applies exclusively to the fields:

  • Reporter (Author);
  • “Assignee” (Contractor);
  • "Fix Version" (Fixed in versions);
  • "Affected Version" (Appears in versions);
  • “Priority”;
  • "Status" (Status);
  • “Resolution”.

The WAS operator can also have the following optional predicates:

  • AFTER "date"
  • BEFORE "date"
  • BY "username"
  • DURING ("date1", "date2")
  • ON "date"
  • FROM "oldvalue"
  • TO "newvalue"

assignee CHANGED - for selecting tasks, performer
which has been changed.

status CHANGED FROM "In Progress" TO "Open" - for selecting tasks
the status that was changed from “In Progress” back to “Open”.
priority CHANGED BY demo_1 BEFORE endOfWeek ()

AFTER startOfWeek () - for selecting tasks whose priority
was changed during the current week by demo_1.

5. JQL functions
FunctionDescriptionSyntaxAvailable operatorsExamples
approved ()Only for JIRA Service Desk.

For the selection of tasks JIRA Service Desk, requiring approval, the final decision on which is approved.

Applies to fields of type “Approvals”.
approved ()=approval =
approved ()
approver ()Only for JIRA Service Desk.

To select JIRA Service Desk tasks that require approval
or already agreed by one or all of the specified users.

Applies to fields of type “Approvals”.
approver
(user, user)
=approval = approver (demo_1,
demo_2)
cascade
Option ()
For selection of tasks by the value of the cascade field (fields of dependent lists).cascadeOption
(parentOption)

cascadeOption
(parentOption,
childOption)
IN, NOT IN"Type of request" in cascadeOption ("Developer",
"Prolongation")
closed
Sprints ()
Applicable to the Sprint field.
For the selection of tasks added to the completed sprints.
closedSprints ()IN, NOT INsprint in
closedSprints ()
components
LeadByUser ()
Applicable
to the "Components" field.

For the selection of tasks, in the “Components” field of which the component is selected, the leader of which is yourself or the user you selected.
Components
LeadByUser ()
is used
for the selection of tasks
by current user
components
LeadByUser
(username)
IN, NOT INcomponent
in components
LeadByUser () -
lead
components
are you yourself.

component
in components
LeadByUser
(demo_1) -
lead
components
is an
user
demo_1.
current
Login ()
Returns the start time of the current user session.

Used in expressions with “Created” fields (Created),
"Due Date"
(Due Date), “Resolved”
(Decision date),
"Updated" (Updated), custom fields of date-time format.
currentLogin ()=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
currentLogin ()
currentUser ()Returns the login of the current authorized user.

Used to create expressions with “Reporter” fields.
(Author),
"Assignee"
(Artist), "Voter", "Watcher" and custom fields of the User format.
currentUser ()=,! =reporter =
currentUser ()

assignee! =
currentUser ()
OR assignee is
Empty
earliest
Unreleased
Version ()
To search based on the earliest unreleased version (i.e. the next version to be released) of the specified project.

Attention
The earliest unreleased version is determined by order, not by date.

It is used to create expressions with the fields "AffectedVersion" (Appears in versions ")," FixVersion "(Fixed in versions), custom fields of the Version format.
earliest
Unreleased
Version (project)
IN, NOT INaffectedVersion =
earliestUnreleased
Version
(ABC)

fixVersion =
earliestUnreleased
Version
(ABC)
endOfDay ()To search by the end of the current day .

Used in field expressions
"Created" (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
“Updated” (Custom), custom fields of date-time format.
endOfDay ()

endOfDay ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 day.

If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
due
<endOfDay () -
period of execution
to end
the current day.

due <endOfDay
("+1") -
period of execution
to end
tomorrow.
endOfMonth ()To search by the end of the current month .

Used in expressions with “Created” fields (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
endOfMonth ()

endOfMonth ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 month.

If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
due
<endOfMonth () -
period of execution
to end
current month.

due <endOfMonth
("+ 15d") -
deadline to
15th day
next month.
endOfWeek ()To search by the end of the current week .

Used in expressions with “Created” fields (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
endOfWeek ()

endOfWeek ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 week.

If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
due
<endOfWeek () -
period of execution
to the end of the current
of the week.

due <endOfWeek
("+1") -
period of execution
to end
next week.
endOfYear ()To search by the end of the current year .

Used in expressions with “Created” fields
(Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
endOfYear ()

endOfYear ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 year.
If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
Due <endOfYear () -
period of execution
to end
current year.

due <endOfYear
("+ 3M") -
period of execution
until the end of March
next year.
issueHistory ()Returns the last 50 tasks you viewed.issueHistory ()IN, NOT INissue in
issueHistory ()
issuesWith
Remotelinks
ByGlobalId ()
To select tasks that have external links with certain global ids.

Attention
The function allows you to enter
global id identifiers
in quantity
from 1 to 100.
Empty function call
or function call
with the number of parameters
> 100 will result in an error .
issues
WithRemote
LinksByGlobalId ()
IN, NOT INissue in
issuesWithRemote
LinksByGlobalId
(abc, def)
lastLogin ()Returns the start time of the previous session of the current user.

Used in field expressions
"Created" (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
lastLogin ()=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
lastLogin ()
latest
Released
Version ()
To search based on the latest released version of the specified project.

Attention
The most recent version released is determined by order, not by date.

It is used to create expressions with the fields “AffectedVersion” (Manifested in versions), “FixVersion” (Fixed in versions), custom fields of the Version format.
latest
ReleasedVersion
(project)
=,! =affectedVersion =
latestReleased
Version (ABC)

fixVersion =
latestReleased
Version (ABC)
linkedIssues ()For the selection of tasks on the basis of the connection with a specific task.

Attention
LinkType is case sensitive.
linkedIssues
(issueKey)

linkedIssues
(issueKey, linkType)
IN, NOT INissue in linkedIssues
(ABC-123,
"Is duplicated by")
membersOf ()To select tasks based on the user's affiliation from a specific field to a specific JIRA-group.

Used to create expressions with the fields "Reporter" (Author), "Assignee" (Artist), "Voter", "Watcher" and custom fields of the format "User".
membersOf
(Group)
IN, NOT INassignee not
in membersOf (QA)
myApproval ()Only for JIRA Service Desk.

To select JIRA Service Desk tasks that require the approval of the current user or already agreed by the current user.
Applies to fields of type “Approvals”.
myApproval ()=approval =
myApproval ()
myPending ()Only for JIRA Service Desk.

To select JIRA Service Desk tasks that require the approval of the current user.
Applies to fields of type “Approvals”.
myPending ()=approval =
myPending ()
now ()To search for the current time .

Used to create expressions with the fields "Reporter" (Author), "Assignee" (Artist), "Voter", "Watcher" and custom fields of the format "User".
now ()=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
duedate <now ()
and status not in
(closed, resolved)
openSprints ()Applicable to the Sprint field.

For selecting tasks added to unfinished sprints
openSprints ()IN, NOT INsprint in
openSprints ()
pending ()Only for JIRA Service Desk.

For the selection of tasks JIRA Service Desk, requiring coordination.

Applies to fields of type “Approvals”.
pending ()=approval =
pending ()
pendingBy ()Only for JIRA Service Desk.

To select JIRA Service Desk tasks that require the agreement of a specific user (s).

Applies to fields of type “Approvals”.
pendingBy
(user1, user2)

projectsLead
ByUser ()
=approval =
pending (demo_1)

approval =
pending (demo_1,
demo_2)
projectsLead
ByUser ()
To select tasks from projects for which a specific user is assigned to the Project Lead role.

Applies to the Project field.
projectsLeadByUser ()
- for the selection of tasks
by current user.

projectsLead
Byuser
(username)
IN, NOT INproject in
projectsLead
ByUser ()
AND status = Open

project in
projectsLead
ByUser (demo_1)
AND status = Open
projects
WhereUser
Has
Permission ()
To select tasks from projects in which the current user has a certain permission .

Applies to the Project field.
projects
WhereUser
HasPermission
(permission)
IN, NOT INproject in
projectsWhere
UserHas
Permission
("Resolve Issues")
AND status = Open
projects
WhereUser
HasRole ()
For selection of tasks from projects in which the current user has a certain project role .

Applies to the Project field.
projectsWhere
UserHasRole
(rolename)
IN, NOT INproject in
projectsWhere
UserHasRole
("Developers")
AND status = Open
released
Versions ()
To search for released versions of a specific project or all JIRA projects at once.

It is used to create expressions with the fields “AffectedVersion” (Manifested in versions), “FixVersion” (Fixed in versions), custom fields of the Version format.
ReleasedVersions () -
for the selection of tasks
for all projects.

releasedVersions
(project)
IN, NOT INfixVersion in
releasedVersions
(ABC)

affectedVersion in
releasedVersions
(ABC)
standard
IssueTypes ()
For the selection of tasks of the parent type.standard
IssueTypes ()
IN, NOT INissuetype in
standard
IssueTypes ()
startOf
Day ()
To search at the beginning of the current day .

Used in expressions with “Created” fields
(Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
startOfDay ()

startOfDay ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 day.

If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
startOfDay () -
tasks created
for the current day.

created>
startOfDay
("-3d") - tasks
created by
last three days.
startOf
Month ()
To search at the beginning of the current month .

Used in field expressions
"Created" (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
startOfMonth ()

startOfMonth ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 month.

If the ± sign is omitted,
it is assumed to be + by default.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
startOfMonth () - tasks,
created by
current month

created> startOfMonth
("+14d") - tasks,
created from the fifteenth
date of the current month.
startOf
Week ()
To search at the beginning of the current week .

Used in field expressions
"Created" (Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
“Updated” (Custom), custom fields of date-time format.
startOfWeek ()

startOfWeek ("inc"),

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 week.

If the ± sign is omitted,
then the default is +.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
startOfWeek () - tasks,
created by
current week.

created>
startOfWeek
("-1") - tasks,
creation date which
older than the beginning
last week.
startOf
Year ()
To search at the beginning of the current year .

Used in field expressions
"Created"
(Created),
"Due Date"
(Period of execution),
"Resolved"
(Decision date),
"Updated" (Updated), custom fields of date-time format.
startOfYear ()

startOfYear ("inc")

where inc is
optional
increment
(±) nn (y | M | w | d | h | m).

If the unit specifier
time measurement omitted
default is used
natural period of function
i.e. 1 year.

If the ± sign is omitted,
then the default is +.
=,! =,>,> =, <, <=
in predicates of the operators WAS, WAS IN, WAS NOT, WAS NOT IN, CHANGED
created>
startOfYear () -
tasks created
for the current year.

created>
startOfYear
("-1") - tasks,
date of creation
which is older
beginning of last year.
subtask
IssueTypes ()
For the selection of subtasks.subtask
IssueTypes ()
IN, NOT INissuetype in
subtask
IssueTypes ()
unreleased
Versions ()
To search for unreleased versions of a specific project or all JIRA projects at once.

It is used to create expressions with the fields “AffectedVersion” (Manifested in versions), “FixVersion” (Fixed in versions), custom fields of the Version format.
unreleasedVersions ()
is used
for selecting tasks
for all projects.

unreleased
Versions
(project)
IN, NOT INfixVersion in
unreleased
Versions (ABC)
voted
Issues ()
To select the tasks for which you voted.votedIssues ()IN, NOT INissue in
votedIssues ()
watched
Issues ()
For the selection of tasks that you are an observer.watchedIssues ()IN, NOT INissue in
watchedIssues ()


I hope that the analysis of the advanced mode will help you when searching for tasks.
Use and do not get lost;)

Source: https://habr.com/ru/post/449932/


All Articles