-->
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.  [ 3 posts ] 
Author Message
 Post subject: Search in RAMDirectory
PostPosted: Fri Feb 02, 2007 1:37 pm 
Newbie

Joined: Fri Dec 15, 2006 6:08 am
Posts: 18
Location: France
Hi,

I want to switch from a FSDirectoryProvider to RamDirectoryProvider.
So in my hibernate.properties I have :
Code:
hibernate.search.default.directory_provider=org.hibernate.search.store.RAMDirectoryProvider


The indexation works well. But I do not manage to search in the index. I would like to get results of searchs in the RamDirectory as an Hits object using org.apache.lucene.search.Searcher.

Here is the code I wrote for FSDirectoryProvider :
Code:
Searcher idxSearcher = new IndexSearcher("myindex");         
Analyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser("content",analyzer);           
String search = "name:" + searchString + " OR type:" + searchString + " OR subtype:" + searchString;
Query query = parser.parse(search);
Hits out = idxSearcher.search(query);


But this code is no longer working with the RamDirectoryProvider. I get an java.io.IOException when initializing the IndexSearcher.

What do I have to do to use a RamDirectoryProvider instead of the FSDirectoryProvider?

Thanks for you help!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 03, 2007 8:04 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
In SVN Branch 3.2
Doing
Code:
Directory dir = ContextHelper.getSearchFactory(session).getDocumentBuilders().get(MyEntity.class).getDirectoryProvider().getDirectory();

IndexSeacher is = new IndexSearcher(dir);
...


If you use 3.2.1, the same info is available from the EventListener (it contains the list of document builders).

I know it's quite complex (probably need to improve that at some point through a helper method), but really the intend is to use FullTextSession and let Hibenate Search find the directory for you.

if FullTextSession does not solve your problem, let me know and I will enhance it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 6:23 am 
Newbie

Joined: Fri Dec 15, 2006 6:08 am
Posts: 18
Location: France
Ok thanks for your reply.
I'm going to test this!


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