Use indexes while indexing
Answered
Hi, my code is throwing a IndexNotReadyException because I need to use some other indexes while indexing one of my index.
Is there a way to solve this (use index inside index processing in a safe way)?
Thanks !!
Please sign in to leave a comment.
Could you please share more details on your project and on what you are trying to achieve?
Hi Serge, the problem is just that, I have two indexes (defined as fileBasedIndex extension points) and inside DataIndexer.map method of one index I need to use the data from the other index, but when I try to access to that index inside DataIndexer.map the IndexNotReadyException is thrown.
Do you mean that you need to access the data of the file being indexed or some other file's data ? Later is not allowed by design
I need to access data from other files too
So there is no way to access the data from index A while generating data for index B? even if index A is already processed?
Well, you can store the necessary data yourself and invalidate it as needed.
Yes, I'm implementing some type of cache for the indexes, but I thought there was an easier and already implemented solution :(
You shouldn't access data from one index while processing another - this may lead to dead-lock according to assertion added in latest IDEA 2016.* so it is forbidden.
Probably You should think about other way to achieve your goal. Probably You are trying to retrieve some information too early - maybe You can do this in lazy way instead?
Indices should be used to map some values and/or reduce them from files in project. You may use it as hints where to find more information about something using key. For every key You receive information about which files contains values related to given key. Then You can access values using key and scope, which determines which files should be scanned for values in given index.
Yes you are right, I'm planning another way to access to that data without mixing indexes. Thanks Marcin !