Forums

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

How can I get a reference to the current indexing process?

JordanJ June 3, 2022

Using script runner, I want to use the java API to check if jira is currently being indexed and if so, i want to pause it temporarily.  I know how to use the indexmanager class to start a new reindex process but I want to check if an index has begun outside of a given script.

 

Specifically, i have a scripted field that makes a jql search.  The search throws an error during indexing.  So i want to check if jira is being reindexed and pause it before the search.

1 answer

0 votes
Nir Haimov
Community Champion
June 17, 2022
JordanJ June 17, 2022

That was my first thought but that only allows me to create a new indexer and start indexing.  I dont see how to grab the current indexing process.

Nir Haimov
Community Champion
June 17, 2022

There must be JAVA API for this, just need to keep searching until you find it.

or, you can try to use this REST API:

https://docs.atlassian.com/software/jira/docs/api/REST/8.14.1/#api/2/reindex

JordanJ June 17, 2022

The rest api allows me to query the currently running index but still no way to stop or pause

Nir Haimov
Community Champion
June 18, 2022

This is required a lot of digging and tests.

But basically, Reindex is a task, so you can use this JAVA API:

https://docs.atlassian.com/software/jira/docs/api/7.2.2/com/atlassian/jira/task/TaskManager.html

to search over all tasks and if there is a "reindex" running, and if yes then cancel it.

However, I think it's not a best practive to stop reindex process, specially not on regular basis, but it's your call.

I would wait for the reindex to stop and than continue what ever you want to do.

Matthew Beda
Contributor
January 12, 2024

How to get the indexing Task ID

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.task.TaskManagerImpl

def TaskManager = ComponentAccessor.getComponent(TaskManagerImpl)
def tasks = TaskManager.getLiveTasks()
for(key in tasks){
if (key.getDescription().contains("Indexing")){
return key.getTaskId()
}
}
Matthew Beda
Contributor
January 12, 2024

To skip field during indexing just "return null" instead of the index ID place it into the top of your scripted field to avoid it trying to use the SearchService for the JQL lookup

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13
TAGS
AUG Leaders

Atlassian Community Events