This script no longer works with ScriptRunner, as the
FilterUtils.getSearchResults method has recently disappeared. I shall fix this in due course, or PRs welcome.
JIRA's reindex screen will be familiar to JIRA admins:
Reindexing is an all-or-nothing affair, and unfortunately it's often really slow when you have lots of issues.
Sometimes you know exactly what issues need reindexing. In my case, it's because I've tinkered with the database directly, bulk-importing issues from another bug tracker. Surely there is some way to reindex just those?
Now there is. Do the following:
- Ensure you have the ScriptRunner for JIRA plugin installed.
- On the filesystem, in your Jira home directory (henceforth $JIRAHOME) you should see a
scripts/directory created by ScriptRunner.
cdinto this directory,
- Download the attached reindexprojects.zip to the server into
$JIRAHOME/scripts/ . I do this by right-clicking, copying the URL (
$url), then running
curl -LOJ $url
- You should now have a file,
- In JIRA type
ggto bring up the admin search, and search for 'Built-in Scripts':
- You should now see a new Reindex projects built-in script:
- Click 'Reindex projects', pick the projects you want to reindex, and click 'Preview' or 'Run':
You might have noticed, there is already a built-in script called "Reindex issues", which does indeed claim to reindex particular projects:
This "reindex" works by.. doing a JIRA search for issues by filter or project, and then reindexing them. Can you spot the flaw in that scheme? Correct - if your indexes are broken to begin with, it's not going to work (and why would you be reindexing unless your indexes were broken?).
The source code, ReindexProjects.groovy is open source. I've reached out to Adaptavist and hopefully they'll incorporate my per-project reindex code.