JQL search returning only Issue Id

Can REST aPI search endpoint return only issue ids?
e.g.: rest/api/3/search?jql=&fields=id&maxResults=5000&startAt=10000&expand=
I would like to query large sets of data, properties as key, expand,self drastically increase payload.

I would like to use search endpoint for determining user view permission for a large number of issues.

1 Like

You can use the Jira expressions REST API to return whatever payload you want based on issues returned from a JQL query. For example, to return only IDs, make the following request:

POST /rest/api/2/expression/eval

{
  "expression": "issues.map(i => i.id)",
  "context": {
    "issues": {
      "jql": {
        "query": "your JQL query",
        "startAt": 0
      }
    }
  }
}

The response will be something like:

{
  "value": [
    10000,
    10001,
    ...
  ],
  "meta": {
    "issues": {
      "jql": {
        "startAt": 0,
        "maxResults": 1000,
        "count": 1000,
        "totalCount": 2500
      }
    }
  }
}

I would use /rest/api/2/search?jql=&maxResults=50&startAt=0&fields=issuekey

You will get following:

{
  "expand": "schema,names",
  "startAt": 0,
  "maxResults": 50,
  "total": 2,
  "issues": [
    {
      "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
      "id": "13227",
      "self": "https://xxx.atlassian.net/rest/api/2/issue/13227",
      "key": "NGES-2"
    },
    {
      "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
      "id": "13226",
      "self": "https://xxx.atlassian.net/rest/api/2/issue/13226",
      "key": "NGES-1"
    }
  ]
}

@kkercz I am wondering what would be more efficient. I was told that generating some columns can influence Jira performance (we are talking here about many requests in short time), therefore you should always add fields to search endpoint requesting only those you need. Now I am wondering whether using expression will be more performant. How expressions are executed internally? Will they be applied after jql results are generated or maybe some complicated logic is behind that and the results are generated faster with expression endpoint?

For this kind of use case, Jira expressions will be at least as fast, if not faster, than the JQL endpoint. Internally, only the issue IDs (or other requested fields) will be loaded from the database during the execution of the JQL query. We analyse the expression to figure out which issue fields need to be fetched.

1 Like

How can I get more than 1000 of maxResults?

I’m afraid 1000 is the limit, both in the JQL and Jira expressions API.

In JQL it is not. I have successfully retrived 5k issues.

Oh, that’s good to know. I see now that the limit in JQL when searching only for ID or key is actually 10k. We should probably make it consistent and raise the limit to that level in the Jira expressions API. But for now unfortunately it’s only 1k in Jira expressions regardless of what your JQL is or what fields you are using.

When could you rise it to 10k?

I would appreciate it greatly.

Our benchmark is to verify issue view permission for 100k issue in less than 1s. If you could rise the limit to 10k I could meet the requirement with 10 concurrent threads.

I created an issue for this: https://ecosystem.atlassian.net/browse/ACJIRA-2242

Thank you.