-->
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: [search]Hibernate search cann't create index
PostPosted: Sun Jun 17, 2007 12:49 pm 
Newbie

Joined: Sun Jun 17, 2007 12:27 pm
Posts: 3
I use hibernate search on windows.
And I try to configure it, how ever when I create a Query and call the query.list() only got the NULLException at NotSharedReaderProvider.java:43.

I checked and find that the index is not created :(. I don't understand why the code did not work. The codes follows the hibernate search document very well.

anyone can share a successful config on windows?

I config the hibernate.cfg.xml as follows:


<property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
<property name="hibernate.search.default.indexBase">e:\\test</property>


.....

<event type="post-update">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-insert">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-delete">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>

===========================

and the java code


public static boolean createIndex() {
Session session = getSession();
FullTextSession fullTextSession = Search.createFullTextSession(session);
try {
List<TBook> bkList = session.createQuery("from TBook").list();

Transaction tx = fullTextSession.beginTransaction();
for (TBook book : bkList) {
fullTextSession.index(book);
}

tx.commit(); // index are written at commit time

fullTextSession.flush();
fullTextSession.close();
} catch (Exception e) {
e.printStackTrace();
}

return true;
}

public static List find() {
FullTextSession fullTextSession = this.getFullTextSession();
try {
QueryParser parser = new QueryParser("bkName", new StandardAnalyzer());
org.apache.lucene.search.Query luceneQuery;
luceneQuery = parser.parse("+hibernate +action");
Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery);
return fullTextQuery.list(); //EXCEPTION happends here**************************************************
} catch (ParseException e) {
e.printStackTrace();
} finally {
if (fullTextSession != null) {
fullTextSession.close();
}
}

return null;
}


public static void main(String args[]) {
createIndex();
find();
}



===========================
and the entity class


@Indexed(index="")
public abstract class AbstractTBook implements java.io.Serializable {
.....

// Property accessors
@DocumentId
public Integer getId() {
return this.id;
}

@Field(index=Index.TOKENIZED, store=Store.YES)
public String getBkname() {
return this.bkname;
}
......
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 10:45 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I can't understand how this could happen (NPE at that line)
Do you have anything earlier in your logs?
Can you post the full stack trace?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 11:37 pm 
Newbie

Joined: Sun Jun 17, 2007 12:27 pm
Posts: 3
because the annotation is marked on AbstractTBook, how ever the pojo class is TBook (extends AbstractTBook). so the "hibernate search" failed to find any pojo class that need indexed.

Is any best practise to solve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 11:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you file a JIRA issue. In the mean time also annotate TBook with the same index name as AbstractTBook

_________________
Emmanuel


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.