I need to clear Lucene cache before reinexing issue.
I found that in previous versions clear caching and reindexing was done as following:
boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); ManagerFactory.getCacheManager().flush(CacheManager.ISSUE_CACHE, issue) log.debug("Reindex issue ${issue.key}") indexManager.reIndex(issue); ImportUtils.setIndexIssues(wasIndexing)
I am using Jira 5.0.5.
what is the coorect way in Jira 5 to run :
ManagerFactory.getCacheManager().flush(CacheManager.ISSUE_CACHE, issue)
Thanks
Community moderators have prevented the ability to post new answers.
Flushing cache manager is no more needed in JIRA5. It wasn't doing anything in the later versions of JIRA too. Try this:
boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); //Do your changes on issue here! log.debug("Reindex issue ${issue.key}") indexManager.reIndex(issue); ImportUtils.setIndexIssues(wasIndexing)
hi Jubin,
I have tried that many times, reindex command runs with no exceptions
but Lucene is not updated.
(in my plugin I update issue status in code. The status is updated correctly in DB but when I search the updated issue using JQL or IssueNavigator I get the issue with old status)
when I run manually reindexAll() everything get fixed but this operation takes alot of time which is not acceptable on end users
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
file : (code.txt)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
my code comes from EventListener when event is updated I check if in linked event status was updates and I update status:
see attached file with full code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you doing the changes to the issue where I have the comment? From your code, you are not doing any issue changes there. Maybe posting the full code will help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Attachment missing..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2 changes. Reindex transResult.getIssue and not newIssue. This might be causing the problem.
Second change, I don't see you are using wasIndexing. You are setting it to true, which is a bad practice. Get the original indexing status, temporarily change to true and set it back to what it was!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wonder if you have some other listener or code doing an indexing after this one the old issue object! Can't think of anything else.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jubin,
changed checkAndUpdateStatuses method got same results after search( I get old status) .
updated code:
IssueIndexManager indexManager= ComponentAccessor.getIssueIndexManager(); boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); int actionid; IssueService issueService=ComponentAccessor.getIssueService(); actionid=getActionIdForTransition(newIssue,transitionname); IssueInputParameters issueInputParams= issueService.newIssueInputParameters(); issueInputParams.setComment("changed by: " + authContext.getLoggedInUser()); TransitionValidationResult transValidResult=issueService.validateTransition( authContext.getLoggedInUser(),newIssue.getId(), actionid,issueInputParams); if(transValidResult.isValid()) { IssueResult transResult=issueService.transition(authContext.getLoggedInUser(), transValidResult); if(transResult.isValid()) { indexManager.reIndex(transResult.getIssue()); ImportUtils.setIndexIssues(wasIndexing); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks a lot Jubin!!!!
You was right I made reindexing twice inside checkAndUpdateStatuses method and afer executing this method.
How is that doing reindexing twice is reverting the index?
notice that in both cases I reindex the new issue (after changing it's status)
the important thing that is working :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what if I want to reindex not an issue but something else like custom field. suppose I am adding NEW option to select list and I dont want to restart my jira but want to reset cache. I assume this one would only help for individual issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
:)
I saw my misspelling :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@NirZ - It was a joke.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what do you mean ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Radu What currency do you prefer?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
CashManager ? That one should be filled, not emptied !!!! :))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.