Hi, the line
Code:
spellChecker.indexDictionary(dictionary, config, true);
is opening an IndexWriter. It also closes it immediately after, but that means that when you invoke this method, you'll need it to point to an unlocked Directory.
At runtime Hibernate Search aggressively opens an IndexWriter to reuse it for any operation; that's a mayor performance benefit as opening IndexWriters is very slow. So since we already have an IndexWriter open on your managed Directory, the index is locked already.
The IndexManager isn't exposing the IndexWriter; and even if it did, this
indexDictionary method doesn't take one.
So options you have:
- configure Hibernate Search to not keep hold on the IndexWriter (releasing locks aggressively); see
exclusive_index_use at
http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html_single/#table-performance-parameters- do what you need to do before the IndexManager starts it's own IndexWriter.
- use a dedicated Directory instance. I think this should be preferred, by extending one of the standard IndexManagers, you can have it use the standard Directory for the usual goals, but in addition create/initialize a secondary Directory which you would use exclusively for this purpose.
Quote:
You expected too much from people that use HSearch in a month :). But I can't see any branch in github for this issue. Do I miss something?
No worries, I don't expect you to make the perfect integration! But if you happen to pull something together and are willing to share it, we can then work on it together to polish it well enough for integration. In your advantage, we would help you with it and then maintain it, plus more users will test it in the next release and future releases. But no pressure and it doesn't need to be done quickly, you can do as you prefer, hack something together and then see if you think it's worth to share or not.
There is no branch in github for this, and I don't think John started on it, nor that he will.. it's an old issue and I'm afraid he won't show up.
To get you started:
Have a look into
org.hibernate.search.indexes.impl.DirectoryBasedIndexManager and make it your base class; extending it is trivial, as you can see in
org.hibernate.search.indexes.impl.NRTIndexManager and org.hibernate.search.test.util.RamIndexManager. The last one is in the testsuite, so you have an example on how to configure it too.
After you've got it working, this might be usefull too:
https://community.jboss.org/wiki/Contri ... nateSearchBTW, you don't need to create a branch in Hibernate Search to create an extension such as a custom IndexManager; you can start simply by having such an implementation in your application:
http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html_single/#d0e871