Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to obtain IssueIndexingService from Plugin-Code?

Johannes Koch October 18, 2015

hi

we have a custom plugin that does varius additions to the workflow options, etc, conditions, etc.

I am trying to migrate this plugin to JIRA7 and I nearly finised.

There is one thing left to do:
We have a few calls, where we actively want to re-index a specific issue.

In JIRA6.3 we did this with

ComponentAccessor.getIssueIndexManager().reIndex(issue);

Reading https://developer.atlassian.com/jiradev/latest-updates/preparing-for-jira-7-0/jira-7-0-general-changes I can see that this is not possible anymore

The IssueIndexManager has been removed from jira-api and is now jira-core — the new jira-api class IssueIndexingService exposes reIndex... and deIndex... methods suitable for add-on use. Additionally, other Lucene0related utility classes have been moved to jira-core.

So, how the hell can I trigger a re-index of a specific issue?

Unfortunately I have not been abled to figure that out.

 

Best regards

Johannes

7 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Johannes Koch December 3, 2015

We ddid this now, and it works out quite well:

 

IssueIndexingService indexing = (IssueIndexingService) ComponentAccessor.getComponent(IssueIndexingService.class);
0 votes
Jerome F_ December 13, 2015

With script runner, I've tried to create to calculate a calculated field which is searchable by JQL queries as following:

  • calculation is processed by a scripted field
  • the scripted field update the value of an integer field
  • force the index of this issue

In facts, it is a bad use of my plugins:

  • scripted fields are actually searchable by JQL queries
  • but scripted field are not searchable by JQL Tricks plugin
  • it is not possible to re-index an issue from a scripted field

So, the good way to proceed is:

  • just use a scripted field without request for re-index, the field is already searchable by JQL queries
  • if you need to create complex condition for your JQL query, just create a new scripted field which manage all those conditions (and don't use JQL tricks for it)

I think everyting is right ok now.

more information here: JIRA 7 : scripting reindex issue => stackoverflow on issueIndexManager.reIndex(issue)

0 votes
Jerome F_ December 10, 2015

How to use it ? I try the following code and I always have a stackoverflow error:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils
boolean wasIndexing = ImportUtils.isIndexIssues();
IssueIndexingService indexing = (IssueIndexingService) ComponentAccessor.getComponent(IssueIndexingService.class);
indexing.reIndex(issue)  // line with the stackoverflow error
ImportUtils.setIndexIssues(wasIndexing);
Johannes Koch December 10, 2015

Hey Jerome. That must be something else, unrelated to that code fragment. If you want, share the exception with me and I can see if i can give you a hint.

0 votes
Jerome F_ December 3, 2015

The same for me. Anyone to show how to use IssueIndexingService? All my custom fields updated by Scrip Runner is no more indexed, thus all my filters are false :-(

0 votes
Johannes Koch November 3, 2015

Nope, I didnt find one yet....

0 votes
Daniel Törnqvist November 3, 2015

Me to. If I was doing a plugin I could just inject the IssueIndexingService into my class constructor. But working on a workflow postfunction I don't really have that option.

0 votes
Mike Wells
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.
October 29, 2015

I have the same problem, did you find a solution yet?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events