Jira Cloud API - how to check if operator is supported?

Eugene Pavliy August 15, 2019

Hi, All.

When working with API, I do have a simple flow like this:

  1. Retrieving definitions of all fields in Jira.
  2. Leave only those, where such is true: it's a text field, it's searchable and not custom.
  3. Then for all that fields I'm using jql to do some search with "Contains". And request line looks like this- executing request like this:
    "/rest/api/2/search?jql=(description ~ \"Desc1*\") OR (statusCategory ~ \"Desc1*\")"

In response I get such error: The operator '~' is not supported by the 'statusCategory' field
I didn't notice any difference in metadata between description and statusCategory fields. Both are searchable and should support "~" from my point of view.

So the questions are:

  • Is it fine that statusCategory field does not work with "~"? Or it's an issue in Jira?
  • Is it somehow possible to say via API, if this field supports cooperation with specific operator?

 

Thanks.

1 answer

0 votes
Krister Broman _Advania_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2019

statusCategory is not text, its a reference of status that can be either "To Do", "In Progress" or "Done". When creating a new status you set the category of the status. This way you can search for any status that is "Done" whether or not the actual status is then "Closed", "Rejected" or anything other that you may have. 

Eugene Pavliy August 15, 2019

Ok, agree. I see the diff in response now between statusCategory and description fields.

Description has schema with indication that's it acts as string, but statusCategory - has no schema in place.

So can you please confirm, that I should treat as text field only those fields, which will return "schema" with string indication in description of the field?

Krister Broman _Advania_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2019

You can use the following functions for statusCategory: =, != , IN , NOT IN 

Eugene Pavliy August 15, 2019

Yep, that's clear, thanks. But what if I just need to get only fields which support ~ operator? I assume these are text fields and all that have "schema" with string type, correct?

Krister Broman _Advania_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2019

There is quite a number of fields that present as texts but are not, so not sure that you can put that as general rule. If theres an issue it would probably be best to check the fields reference: https://confluence.atlassian.com/jirasoftwareserver071/advanced-searching-fields-reference-800707156.html 

Although some fields are not even shown there like statusCategory. 

Eugene Pavliy August 15, 2019

Great. Cause for now I've just implemented workaround, if field does not support "~" operator - I just do retry with that field.

Based on your last post, it looks like acceptable.

Thanks.

Krister Broman _Advania_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2019

One thing that might help is the text function: https://confluence.atlassian.com/jiracorecloud/search-syntax-for-text-fields-765593720.html 

That function will search all text fields at once, so if you are just looking through all text fields fields for a specific search option that should be enough. 

Suggest an answer

Log in or Sign up to answer