-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: [Hibernate Search] indexes overwritten at launch
PostPosted: Fri Oct 19, 2007 12:48 pm 
Newbie

Joined: Fri Oct 19, 2007 11:44 am
Posts: 5
Please excuse my english, since it's not my native language.

Hibernate version:

Hibernate core 3.2.4.sp1
Hibernate search : 3.0.0.GA
Hibernate annotations : 3.3.0.GA

I'm currently using Hibernate in a end-user application. I'm currently running on a problem whose cause I can't understand.

Each time I launch my application, all the indexes created by lucene get cleared, and as such, if I don't manually index my data again, I can't use it. The fact is : I think manually indexing the database again could be too long to be bearable by the user, and in fact, I don't understand if the deletion of the previously created indexes is a feature of hibernate search (or lucene), or if I'm just doing something wrong. Shouldn't the old indexes be reused ?

The connection to the database is programmaticaly configured, does it play any role here ? I don't know where to look first, and didn't find anything on indexes deletion or reusing in the manual.

then again, I could have missed it, I'm lost here. I don't even know what information could be relevant to get help. :/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 7:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate Search does not erase the Lucene directories, so it come from somewhere else.
Are you sure you use a FSDirectoryProvider (and not a RAMDirectoryProvider)?
Check the indexBase property (check the doc for the full name), to see if the index is persisted while your app is running

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 7:18 pm 
Newbie

Joined: Fri Oct 19, 2007 11:44 am
Posts: 5
Thanks for the answer.

I do use a FSDirectoryProvider, and I configured its base directory. When I go in one of the subdirectoriez containing the indexes with Explorer, I do see many files being created, updated, and increasing in size as long as the application does its work. When I quit the application, the files are still there. The problem occur when I launch the application again : the files disappear, and instead I find two little files which seems to be empty indexes.

It seems to me that hibernate search or lucene doesn't like its old indexes and replace them with new, cleaner ones, yet I don't see why.

edit : here is more info :

the new files created at launch are named "segments.gen" and "segments_12r".

When I try to open the index with Luke, I get an error : "invalid or corrupted index".

Still, if I reindex manually the database, with session.index(), I do have a correct index that I can open and read with Luke.

my config for hibernate search is :
Code:
# the default directory provider
hibernate.search.default.directory_provider org.hibernate.search.store.FSDirectoryProvider

# the default base directory for the indecies
hibernate.search.default.indexBase = .focus_search_indexes   


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 20, 2007 11:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hum I really don't see.

Maybe try to change

hibernate.search.default.indexBase = .focus_search_indexes

to

hibernate.search.default.indexBase = ./focus_search_indexes (or \ on windows)

If that makes it, there might be a bug in the directory discovery or the vm, let me know. If it still does not work, give the debugger a try, the directory thing happen in the FSDirectoryProvider

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 20, 2007 1:14 pm 
Newbie

Joined: Fri Oct 19, 2007 11:44 am
Posts: 5
Thanks, I'll try all that. I'm using a .directory name in order to have it hidden under unix file management system.

I'm also willing to try without underscores in the name (why not ?)

I'll keep you informed.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 22, 2007 10:54 am 
Newbie

Joined: Fri Oct 19, 2007 11:44 am
Posts: 5
So I tried renaming the file without dots not underscores, with no success.

Then I launched my debugger, and I realized that in the FSDirectoryProvider.initialize() method, it always went through this

Code:
File indexDir = DirectoryProviderHelper.determineIndexDir( directoryProviderName, properties );
boolean create = !indexDir.exists();
[...]
if ( create ) {
   IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), create );
   iw.close();
}


create was always true because my indexBase was configured like this :

.focus_search_indexes

Don't see it ? me neither, until I checked in the debugger : there were 3 trailing spaces at the end of the config line, just after the directory name.

Still, I wonder if it means that something should be done on the hibernate side of the code to prevent such errors again, since it worked partially and never returned a configuration error. Do you usually trim this kind of Strings ?

That said, thanks a lot for the guidelines on how to find my error. It's really nice to get answers so quickly and effectively.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I would be inclined to do a trim, but actually 'mydir ' is a perfectly valid directory name AFAIK.
At least we should provide better log infos, please open a JIRA issue to enhance the logs

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 23, 2007 5:54 pm 
Newbie

Joined: Fri Oct 19, 2007 11:44 am
Posts: 5
Thank you very much.

http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-130

Still I would like to discuss that last part.

If trailing space are not a problem for a valid directory name, why is it that HibernateSearch didn't create the directory with trailing space and used it, but used the one without those trailing spaces ? It used the one in which older indexes already existed, and it recreated them, clearing all existing content.

I can understand if it's on the JVM or the OS side that the problem resides, but still, Hibernate Search behaviour here seems quite illogical to me.

But yes, I know, I'm the one at fault here. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.