Like query operator in Jira’s JQL by Josh Sherman

0
19

Jira’s query language (JQL) is a query language similar to SQL. That being said, the syntax for doing something similar to SQL’s LIKE statement is nothing like how you’d do it in SQL.

While deviating from the syntax that was used for inspiration isn’t uncommon, it’s quite peculiar that the word “LIKE” is also a reserved word in JQL, even if it’s not used explicitly for fuzzy matching.

In JQL, they refer to “like” statements as “contains”. The “contains” operator is the tilde ~ and looks something like this:

field ~ searchtext

The operator allegedly attempts to match on derivatives so searching for “file” will also match “files”.

The operator also supports wild cards, and uses an asterisk * instead of SQL’s wild card characters:

field ~ "searchtext*"
field ~ "*searchtext"

If you are searching for a multiple word phrase, keep in mind that including a space in your search text implies “match BOTH of these words”:

field ~ "this that"

Which will search for “this” and “that”. If you’re looking for “this that”, you’ll need to quote (and escape) the string like this:

field ~ ""this that""

And if you’re looking for things that don’t contain something, simply slap a bang ! on the operator:

field !~ searchtext

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

Source

LEAVE A REPLY

Please enter your comment!
Please enter your name here