-->
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.  [ 4 posts ] 
Author Message
 Post subject: Manual Indexing Quietly Does Nothing
PostPosted: Fri Aug 29, 2008 9:36 pm 
Newbie

Joined: Thu May 08, 2008 2:34 pm
Posts: 6
Twice I have been frustrated when calling FullTextEntityManager.index() and it returning quickly and quietly doing nothing. Here are the reasons for those two cases:

The first time, I had been calling index() with an instance of Article which extends from ContentItem. While ContentItem had been annotated with @Indexed, Article had not. Annotating Article with @Indexed solved the problem.

The second time was due to the fact that I was calling index() in the context of a transaction. In this case, the indexing work is placed on a queue to be done later. Making sure that I commit any outstanding transaction before starting my manual indexing solved this problem.

Both times, I had enabled DEBUG logging for org.hibernate.search, but nothing was printed. The latest version of search (3.1.0.Beta1) now throws an IllegalArgumentException for the first case.

If you guys can do something to address the second case, it might save some poor hapless users the pain I endured.

Thanks!
Phil


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2008 4:04 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello Phil,
thanks for your feedback, as you have already seen with the latest update the developers are trying to make better warnings and errors, but I'm afraid the second "issue" is actually a strong feature of Search: to keep the index consistent with the database it will not be updated unless you commit your changes to the entities, so even printing a warning would be misleading:
You should always use transactions, and don't expect anything to be done until you commit.

Quote:
If you guys can do something to address the second case, it might save some poor hapless users the pain I endured.

I agree, I became contributor myself to improve it on the points I have had to endure;-)

Do you think we should add additional warnings on the documentation?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2008 10:04 am 
Newbie

Joined: Thu May 08, 2008 2:34 pm
Posts: 6
Hi,
Thanks for accepting my feedback so graciously.

Now that I understand the situation, I agree that an error or even a debug message is not appropriate. The behavior makes sense to me now :)

Although I think it's best to make API's self-describing, in this case, it's probably a documentation issue.

The thing is... it never occurred to me that manually indexing all the objects in my database should involve transactions. But, now that it's pointed out, it makes sense. The fact that indexing is not part of the EntityManager API threw me off, I suppose.

Here's the current javadoc for index():
Force the (re)indexing of a given managed object. Indexation is batched per transaction

Here's my new understanding of how index() works:
Initiate the (re)indexing of a given managed object. If a transaction is active, the indexing work will be performed when the transaction is committed. Otherwise, the indexing work will be performed immediately.

Perhaps just updating the javadoc to something like that would help.

One thing I just noticed also, about this example:
http://www.hibernate.org/hib_docs/searc ... le/#d0e253

The JPA example does not show the use of a transaction, although the Hibernate version does. I suspect I ignored the hibernate example and just looked at the JPA one.

Thanks for volunteering to work on hibernate!
Phil


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2008 10:43 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
thanks, I'll see if I can update the docs ;-)

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.