问题
In my application I am going to implement hibernate lucene. My application will be deployed in clustered environment.
Now, I am not able to find out how, I can point out the location of all the lucene index to a shared location. So it can be accessed through the network.
回答1:
You can, but it's not as simple as having a shared directory: two instances of your application cannot access the same index files simultaneously.
Thus, the preferred solution is generally to:
- Have only one "master" node access a "master" copy of the index, and have all other nodes send "write requests" to this "master" node.
- Periodically copy the "master" copy of the index to "slave" nodes, so that they can read it, even though their copy will always be slightly out of date.
Hibernate Search provides implementations for both mechanisms:
- The master/slave architecture is implemented thanks to a JMS backend or a JGroups backend. Note that the JMS backend is noticeably less buggy. Also note that you will have to configure JMS or JGroups yourself, and that may require some expertise too.
- The copying is implemented thanks to the filesystem-master and filesystem-slave directory providers.
So, that's a bit complex.
Another option, perhaps easier, is to use the Elasticsearch integration, moving the index to a remote cluster. It's simpler to use, but has some rough edges as it's still experimental.
We plan to bring first-class support for the Elasticsearch integration in the next version of Hibernate Search, version 6.
来源:https://stackoverflow.com/questions/54759834/how-to-set-hibernate-lucene-index-to-be-pointed-to-shared-location-so-no-index