-->
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.  [ 2 posts ] 
Author Message
 Post subject: how to get IndexSearcher?
PostPosted: Sat Jul 17, 2010 3:17 am 
Beginner
Beginner

Joined: Mon Oct 27, 2008 6:26 am
Posts: 36
Hi gurus,

I am trying to load document from lucene directory directly. but each time to new a IndexSearcher instance looks like a time consuming job.

As hibernate search in action states, "To keep Lucene as efficient as possible, you should reuse the same IndexSearcher or
IndexReader. Lucene works best after the searcher has warmed up. You’ll need to keep the searcher around for as long as you can, but not too long; a searcher doesn’t see the changes made after it is opened.", so it is better to reuse IndexSearcher for query. I wonder, is any way available to get IndexSearcher in hibernate search api, therefore I can resue it.

I also hope someone can tell me how hibernate search cache IndexSearcher.

thanks


Top
 Profile  
 
 Post subject: Re: how to get IndexSearcher?
PostPosted: Sat Jul 17, 2010 4:48 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
I also hope someone can tell me how hibernate search cache IndexSearcher.

Internally it uses the configured ReaderProvider implementation, the default one is the most efficient reopen() of the index, so it will check for the need of reopening a new one. You can configure another implementation from the provided set, or write your own one. But in any case in your code if you know you won't need a new one you can keep the reference to the IndexReader for a long time.

On FullTextSession there's a method to getSearchFactory() and this exposes both getReaderProvider() and getDirectoryProviders(Class<?> entity),
you can get the DirectoryProvider for a specific type from the latter and then use the first to get an IndexReader - this is in case you're not using HS search api, as it uses them behind the scenes without need to worry.

_________________
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.  [ 2 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.