Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Re-Index the all issues in the project using Script runner??

mani@123
Contributor
July 25, 2019

Hello All,

I am trying to Re-Index the all issues in a project for every 1 minute with the Script Runner Escalation services using below script. However, it is Re-Indexing only particular issue every time.

import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.util.ImportUtils
import org.apache.log4j.Category

def issueManager = ComponentAccessor.getIssueManager()
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)

boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
log.warn("Reindex issue ${issue.key} ${issue.id}")
issueIndexingService.reIndex(issueManager.getIssueObject(issue.id));
ImportUtils.setIndexIssues(wasIndexing);

 Can any one please help.

Thanks in Advance,

Mani

1 answer

0 votes
Nic Brough -Adaptavist-
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.
July 25, 2019

>Re-Index the all issues in a project for every 1 minute

WHY???

This is something you should never never even start to think about doing.  It will consume a massive amount of resources for no benefit I can work out.

What makes you think you want to do this?   Could we look at fixing whatever is making you think you want to do it instead of implementing a really bad solution?

mani@123
Contributor
July 25, 2019

Hi Nic,

We want to prioritize and sort the issues based on a Calculation custom field values.

Currently, once the calculation field is updated issues are not sorting in ASC  or DESC order.

attachement.PNG

However, issues are prioritizing and sorting accordingly once we Re-index the project.  Re-Index Project is only available for Jira administrators, Project admins cannot come to us every time to Re-index the project after updating the custom field. 

So we decided to run a script every minute so all issues will Re-index. If you think it is not a right way of doing could you please suggest any other method?

Thanks in Advance,

Mani

Nic Brough -Adaptavist-
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.
July 27, 2019

I don't "think is is not right", it is utterly utterly wrong.  If you do this every minute, you're going to load your server to the point of uselessness within seconds.

You need to look at what you are doing with this "prioritisation" that is failing so badly - any proper change of an issue will index it correctly, and it sounds like what you are doing is broken because it is not.

Suggest an answer

Log in or Sign up to answer