How to rebuild index on demand?
I'm trying to manually rebuild my custom file based index by invoking an action from menu (i.e. for debug purposes). I'm doing this by com.intellij.util.indexing.FileBasedIndex#requestRebuild method, but this method not cause index rebuild right now, but rather at next usage of this index. What should I do to force reindexing at this moment from action?
Please sign in to leave a comment.
why not query your index after requestRebuild in your action?
Yes, accessing index triggers index rebuild. Also changing com.intellij.util.indexing.FileBasedIndex#requestRebuild to com.intellij.util.indexing.FileBasedIndex#scheduleRebuild do the trick. But in real I need to refresh 3 indices at once and this seems to be a problem for IDEA. I do this in actionPerformed:
IDEA triggers rebuild for all 3 indices, but only first one is properly rebuild - second and third are marked as REBUILD_IN_PROGRESS and then as OK, but they are invalid (no values in index). Also, accessing index after this do not triggers index refresh, so data are still invalid. This seems like a bug or thread racing issue to me but maybe I use it in wrong way? Problems probably start from com.intellij.util.indexing.FileBasedIndexImpl#checkRebuild
I just want to refresh selected indices without restarting IDEA.
Workaround:
Is this workaround the correct way to do this? I'm having the same problem, I can't force the reindex, and this workaround is not working either.
Currently I do this in similar way, but using queue mechanism instead nested runnables (only for debugging purposes in IDEA 12.1). Can You describe what kind of problem You have?
Actually I think is working fine now, I had an error in one of my indexes and I guess that was the problem with the reindex. Thanks !!