Reindex of issue in scriptrunner service for scripted field sometimes don't work

Hi,

I'm using a scripted field (scriptrunner) for calculating  a response time.
I use s scriptrunner service for reindexing issues with high priority.
Most of the time the value for the scripted fied is fine and search works.

But sometimes the values are wrong => calculated field hold wrong values on search.

I can't find the reason why most of times it works and sometimes not.

Below the code of my reindex service (runs every 30 min)

Thanks for any hint

Dieter

jqlSearch = 'project = IM and status = Offen and priority = "Major incident"'; 

userManager              = (UserManager)  ComponentAccessor.getUserManager();
ApplicationUser appUser  = userManager.getUserByKey("admin");
User user                = appUser.getDirectoryUser();

ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(ApplicationUsers.from(Assertions.notNull("user", user)));

SearchService searchService     = ComponentAccessor.getComponent(SearchService.class);
IssueManager issueManager         = ComponentAccessor.getIssueManager();
IssueIndexManager indexManager     = ComponentManager.getInstance().getIndexManager();

List<Issue> issues = null;
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);

if (parseResult.isValid()) {
    def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
 
    issues = searchResult.issues;

    issues.each() { Issue issue ->
        boolean wasIndexing = ImportUtils.isIndexIssues();
        ImportUtils.setIndexIssues(true)
        MutableIssue myIssue = issueManager.getIssueObject(issue.id);        
        indexManager.reIndex(myIssue);
        ImportUtils.setIndexIssues(wasIndexing);    
    }
}
 else {
    log.error("[Index Service] Invalid JQL: " + jqlSearch); // Log errors if invalid JQL is used so we can fix it
}

 



1 answer

1 accepted

Hi Dieter,

Did you try to disable cache in your scripted field script ? Many inconsistencies are because of caching.

No I did not.
So I just have to include

enableCache = {-> false}

at the beginning of the script?

yes that's right, and when you make sure that this solves your inconsistency problem, then (if the reIndexing was to address that issue only) you can discard the reIndexing service.

Perfect, that was the solution
Great thanks Thanos

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

75 views 0 5
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