Why does the text ~ search syntax pick up the previous version of a post edited through the API?


My organization has developed a script to export JIRA issues into an XML format, pass them through translation software, and then use the API to edit the JIRA issues to post the translations.

Content is marked as needing translation by adding a mention to a specific account ("accountname" below). We have a query that looks for these issues, something like:

project in (XXX) AND text ~ accountname

The API is successfully able to post the translation, which involves editing the target item (description or comment) to delete the request mention and paste in the translation content. However, after we do this, the issue still shows up in the query, even though the "accountname" text has been removed from the entire issue.

We verified the JSON and found that the only place the text still exists is in an "oldDisplayValue" field:

 "oldDisplayValue" : "Testing auto-translation\r\n\r\n[~accountname]",

We want to continue to use the query as a visual check to make sure that all of the issues marked for translation have been picked up and handled, but because of the false positives, we currently have to go to each post after the API edits it and do another manual edit (just open it and save so the "last edited" user changes). This removes it from the query.

Anybody know why this is not working?

1 answer

0 votes

Hi Dillon,

Do you use REST API or Java API (say, with Script Runner)? One case where this would happen is if you somehow make the changes without reindexing the issue. Please check that or post the code of how exactly you are updating the issue.

I'm also intrigued by "oldDisplayValue". Could you please post a larger part of JSON around this property, up to the field level?


Igor, thanks for the response. I'm not actually the programmer myself, but here's the info I received. We use the REST API.

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.ContentType = "application/json"; request.Method = method; // POST   if (data != null) {     using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))     {         writer.Write(data);     } }


“data” consists of something like the following. Each of those are pushed in separate chunk. (e.g. in the case of the following, it makes three “writes” to the post, to /rest/api/latest/issue/[postid]  

{"update": {"summary": [{"set": "Test | Test"}]}}  

{"update": {"description": [{"set": "Test\r\n\r\n----\r\n\r\nTest\r\n{color:lightgray}Test{color}"}]}}  

{"update": {"comment": [{"edit": {"id":[id],"body":"Test\r\n\r\n----\r\n\r\nTest\r\n{color:lightgray}Test{color}"} }]}}

The programmer also said that he only sees an option to reindex the whole site, which would take too long and can only be done by a site admin.

Here's a bit more of the JSON:

        "author" : "XXX",
        "created" : 1495678441000,
        "items" : [ {
          "fieldType" : "jira",
          "field" : "description",
          "oldDisplayValue" : "Testing auto-translation\r\n\r\n[~accountname]",
          "newDisplayValue" : "Testing auto-translation\r\n\r\n----\r\n\r\n自動翻訳テスト\r\n{color:lightgray}#t9n{color}"



Hi Dillon,

Thanks for the details. The REST API should reindex the issue, so I guess my idea was not related to this case.

The "oldDisplayValue" seems to come from the history of changes, which is not searched with "text ~".

Have you tried "description ~ value" instead of "text ~ value"?

Kind regards,

Hi Igor, thanks for your prompt responses!

We are also looking for mentions in comments, so just "description ~ value" wouldn't work, but we did originally try with "(description ~ value OR comment ~ value OR summary ~ value)" and narrowed it down to picking up on "comment ~ value". That may be relevant information, actually, if the only part of an issue we have touched with the API is the description, it does NOT return a false positive in the query. This only occurs for the comments, and according to the JSON file, oldDisplayValue is the only place in the comment that the string occurs, so it appears to us as though something is causing "text ~ value" (or "comment ~ value") to pick that up.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,114 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you