S-JQL Reference

This article is for Data Center. Visit Cloud

S-JQL Reference

Structure query is a hierarchical condition on the items added to the structure. Structure query is expressed in the Structured JQL language (S-JQL), described in this article.

Parts of this article assume that you are familiar with Advanced Searching capability of JIRA.

Multiple instances of items

If there are multiple instances of an item in the structure, some of these instances might match the query, and some might not.

Consider the following structure:

TS-239 TS-42 TS-123 TS-239

Here, issue TS-239 is present two times — one at the root position, and another under another issue. Query root will match the first instance but not the second one.

This difference is visible when you are filtering in the Structure Widget (see Filter). However, structure() JQL function matches an issue if at least one of its instances in the structure matches the S-JQL query. In this example, issue in structure(root) will return TS-239, TS-123.

Constraints

Structure query consists of constraints. A constraint matches items in the structure. In the simplest case, the whole structure query consists of a single constraint; for now, we will consider only this case.

There are two types of constraints: basic and relational constraints.

 

Basic constraint

A basic constraint matches items that satisfy a condition — regardless of their relative positions to other items.

JQL constraint

JQL constraint matches all issues in the structure that satisfy a JQL query. To specify it, specify the JQL query enclosed in square brackets:

[status = Open]

leaf and root 

This basic constraint matches items that are located at special positions within the structure.

leaf



root

The first constraint matches items at the bottom level of the hierarchy, i.e., items that do not have children (sub-items).
The second constraint matches items at the top level of the hierarchy, i.e., items that do not have a parent.

Specific issue

This kind of basic constraint matches just the referenced issues. If some of the issues are not contained within the structure, they are ignored. If none of the issues are contained within the structure, the constraint matches no issues.

You can specify a comma-separated list of issue keys:

TS-129, TS-239

One issue key:

TS-129

Issue ID (or a list of them):

19320

Function constraint (folder, item)

Functions in S-JQL play the same role as in JQL: it is an extension point, so any vendor can develop their own functions to match items in a custom way. 

Structure comes bundled with a few functions: folder (matching all folders or folders by name) and item (matching all items of the specified type or items by name).

Syntax

A function constraint has a name and zero or more arguments, depending on the function you are using:

folder(Urgent)

In the example above, function name is folder and its argument is Urgent.

You can insert any amount of spaces around the name and arguments:

folder ( Urgent )

Multiple function arguments should be separated by commas:

item(Status, In Progress)

If an argument contains commas or parentheses, you need to enclose it in "double quotes" or 'single quotes': 

item(Status, "Done, Sealed, and Delivered") folder("NU (non-urgent) issues") 

The former example matches Status items in structure that are named Done, Sealed, and Delivered. If this name wasn't enclosed in quotes, the query would mean that function item is given four arguments: StatusDoneSealed and and Delivered.
The latter example matches folders named NU (non-urgent) issues. If quotes were not used, the query would be incorrect because the first closing parenthesis would be understood as the end of folder's arguments.

If your argument contains quotes, you need to use another type of quotes to enclose it. Suppose that you need to match a version named 3.0, 3.0.1 "Armageddon":

item(version, '3.0, 3.0.1 "Armageddon"')

You can also escape the quotes using backslash (\). Suppose that the version is named 3.0 Beta 1 "Armageddon's Near":

item(version, '3.0 Beta 1 "Armageddon\'s Near"')

If you need to use backslash character on its own, you can escape it with another backslash (\\). Suppose that you need to match a folder named \ (backslash) and related characters:

folder ('\\ (backslash) and related characters')

Note that if you don't need to enclose your argument in quotes, then you don't need to escape quotes or backslashes contained within it:

folder (Joe's) folder ( \ )

Finally, if there's only one argument and the argument doesn't contain spaces (or is enclosed in quotes), you can omit the parentheses:

folder Urgent folder "Not urgent"

folder()