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

Dillon Brown August 10, 2017

Hello,

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
Igor Sereda [ALM Works]
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 11, 2017

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?

Cheers,
Igor

Dillon Brown August 14, 2017

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}"

 

Thanks!

Igor Sereda [ALM Works]
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 14, 2017

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,
Igor

Dillon Brown August 14, 2017

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