JQL actual "contains"
Asked Answered
W

2

8

I want to perform a simple search on a text field with part of its content but I don't know the beginning. I basically want what someone would expect of a "contains search". If I search issue for 345, I would want this result:

123456
234567
345678
...

Which, in JQL, would be the result of the query issue ~ "*345*", but the * is not allowed as first character in wildcard query. Is there an easy way to get this result, preferably with a JQL query?

Welloff answered 22/5, 2017 at 9:25 Comment(0)
C
5

Filter issues by "345" substring in the Summary field:

summary ~ "345"

Filter issues by "345" substring in the Description field:

description ~ "345"
Cannonade answered 3/8, 2021 at 11:2 Comment(1)
This searches for it as a whole word. It won't find values like "123456", as precised by the answer from grundicAbagael
C
4

Right now it's impossible to search JIRA for contains operation. As described in Search syntax for text fields, JIRA support Word stemming:

Since JIRA cannot search for issues containing parts of words, word 'stemming' allows you to retrieve issues from a search based on the 'root' (or 'stem') forms of words instead of requiring an exact match with specific forms of these words. The number of issues retrieved from a search based on a stemmed word is typically larger, since any other issues containing words that are stemmed back to the same root will also be retrieved in the search results.

That means, that you can search for common root of some word, but can't search for arbitrary part of it.

There is an issue in official JIRA bug tracker: Allow searching for part of a word (prefix / substring searches), which describes why this can't be implemented:

Lucene doesn't support prefix search.

As a workaround the suggestion is to use Script Runner plugin for JIRA:

issueFunction in issueFieldMatch("project = JRA", "description", "ABC\\d{4}")

See more on IssueFieldMatch here.

Another plugin, which can do regex jql is JQL Search Toolkit.

Cloudy answered 22/5, 2017 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.