Re-index issue on work log changes

We have a custom field that checks to see if a user has logged work on any issues in the last N days.  The field uses the worklogged issue function and returns the number of issues that have work logged on them.  We then run a query to find all users whose value for this field is 0.   When work logs are recorded, the custom field returns the correct updated value, but the search index is not updated, so the query returns the old value.   

Running full re-index manually fixes the issues, but we will need an automated solution.

What would be the best way to trigger a re-index of the custom field's value so search results work correctly?

Using JIRA 6.3.5 and ScriptRunner 3.0.5

2 answers

1 accepted

1 vote

Using the script-runner, add a simple listener to catch "work logged", "work log updated", "work log deleted" etc events.  It can then re-index the appropriate issue.  (Work log moved to another issue is a bit more of a pain as you'd need to index both)

Creating an issueWorkLogged listener appears to be working by indexing the relevant issue. Thanks for the help.

0 vote

Your question only makes sense if you're using a custom field to record work logs on linked issues. If it's the current issue, it will get reindexed when a work log is added.

There is an example of reindexing linked issues using an event handler here: https://scriptrunner.adaptavist.com/latest/jira/recipes/scriptfields/workRemainingInLinkedIssues.html#_indexing (but read the section above too).

Yes, we are using a custom field that queries for worklogs on other issues. Thanks for the examples.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,223 views 14 19
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot