CDV ❯ Support for Hibernate Search
-
New Feature
-
Status: Resolved
-
2 Major
-
Resolution: Won't Fix
-
-
-
siyer
-
Reporter:
-
December 18, 2007
-
6
-
Watchers: 5
-
August 31, 2012
-
August 31, 2012
Attachments
Description
Hibernate search is a Wrapper around lucene 2.2.0 that lets create and search lucene index using hibernate APIs. For details refer to http://search.hibernate.org and forum post http://forums.terracotta.org/forums/posts/list/691.page
Comments
Stefan F 2008-04-28
Stefan F 2008-04-28
Patch to make org.hibernate.search.store.RAMDirectoryProvider to org.hibernate.search.store.ClusteredRAMDirectoryProvider
Dominic Tootell 2008-07-09
Stefan F.
Thank for the patch, I was just looking at doing this myself.
One thing I was wondering about though, is if just providing a Custom DirectoryProvider is enough. Looking at the example code for the lucene tim [0], synchronization is made on the lucene RAMDirectory when used for reading and writing (via IndexReader and IndexWriter); and mirrored in the tc-config.xml.
This made me think that you’d also have to provide auto locks, and instrumentation, in the terracotta configuration; for anywhere that the RAMDirectory was used in Hibernate Search. Meaning all the places within Hibernate Search code itself that uses the RAMDirectory.
Maybe I’m over analysing it; or misunderstanding the terracotta-lucene-examples.
What do you think?
[0] http://svn.terracotta.org/svn/forge/projects/labs/terracotta-lucene-examples/trunk/terracotta-lucene-examples/src/main/java/org/terracotta/lucene/example/RAMDirectoryExample.java
/dom
Stefan F 2008-07-09
To be honest, I don’t use RAMDirectory anymore. It turned out to be very slow, especially with bulk indexing of data. I therefore use a Lucene Directory implementation by Compass (http://www.compass-project.org/): http://svn.compass-project.org/svn/compass/trunk/src/main/src/org/compass/needle/terracotta/
Also note the open JIRA issue: http://issues.compass-project.org/browse/CMP-673
However, the example looks as if RAMDirectory is used without any autolocking and so on. It rather synchronized any access to the directory which definitely isn’t what you want to do if you at least require some degree of acceptable performance in a highly multi-threaded (clustered) environment.
Regards, Stefan
Stefan F 2008-07-09
see also http://jira.terracotta.org/jira/browse/CDV-338 for Compass’ TerracottaDirectory
Dominic Tootell 2008-07-09
Stefan.
Thank you very much for the information,. I’ll take a look at the compass implementations; and the links in the other jira.
/dom
Alex Miller 2008-09-08
By the way, I started to build a TIM based on this snippet here:
http://svn.terracotta.org/svn/forge/projects/labs/tim-hibernate-search/trunk/
but never had time to finish it. But it’s a start. Of course, the Compass direction is the better one, I think.
Jirka Hradil 2009-04-22
Hello, what about using this solution: http://blog.hibernate.org/9692.lace It’s look extremely simple, what do you think? I would like to test it and I give you a report, but maybe someone did it already.
I’ve found a wokraound for Hibernate Search and Terracotta: You can use tim-lucene-2.2.0 [0] and write your own DirectoryProvider for Hibernate Search.
What I did was really simple: I copied an existing DirectoryProvider (namely org.hibernate.search.store.RAMDirectoryProvider [1], LGPL licensed I guess) that uses org.apache.lucene.store.RAMDirectory for Lucene, which is the way to use Lucene 2.0 with Terracotta (“Client apps will need to declare a RAMDirectory field, and mark it as root.” [2]). The only thing that was missing was a root. I solved this by adding a Map to my copy of org.hibernate.search.store.RAMDirectoryProvider (I copied those 4 methods as sub-classing would not be easier due to private fields).
The last missing steps were to use this DirectoryProvider:
hibernate.default.directoryProvider=org.hibernate.search.store.ClusteredRAMDirectoryProvider
and make the map a root:
For me it seems to work, even with multiple directories. However, I haven’t tested it in production (yet).
[0] http://svn.terracotta.org/svn/forge/projects/labs/tim-lucene-2.2.0/ [1] http://viewvc.jboss.org/cgi-bin/viewvc.cgi/hibernate/search/tags/v3_0_1_GA/src/java/org/hibernate/search/store/RAMDirectoryProvider.java?revision=14343&view=markup [2] http://terracotta.org/confluence/display/integrations/Lucene