Abdessamad Tmr
Abdessamad Tmr

Reputation: 13

java - hibernate search indexing not working

I m trying to integrate hibernate search in my existing application. According to the tutorial of hibernate search i have added following properties in hibernate properties in applicationContext.xml

<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>  
<prop key="hibernate.search.default.indexBase">./lucene/indexes</prop> 

Also i have added the annotation on the entity classes for which i want to enable search. Using @Indexed on class and @Field on the fields.

Following are the versions i am using (I'm not using maven):

and I'm using this sample code to perform a search in MySQL database :

public void search() {

FullTextSession searchSession = Search.getFullTextSession(sessionFactory.getCurrentSession());

QueryParser parser = new QueryParser(Version.LUCENE_32, "contenu", new StandardAnalyzer(Version.LUCENE_32));

org.apache.lucene.search.Query query = parser.parse("décarbonateront");

org.hibernate.Query hibQuery = searchSession.createFullTextQuery(query, Book.class);

List result = hibQuery.list();

System.out.println("lucene results: " + result.size());

}

But I get this error : The type org.hibernate.classic.Session cannot be resolved. It is indirectly referenced from required .class files

at : searchSession.createFullTextQuery(query, Book.class);

What can be the problem ??

Upvotes: 0

Views: 1956

Answers (1)

Hardy
Hardy

Reputation: 19109

You need to align the Hibernate and Hibernate Search versions. You need Hibernate 3.5.x for Hibernate Search 3.2. Check the versions for example in the Maven pom - https://repository.jboss.org/nexus/content/repositories/public/org/hibernate/hibernate-search-parent/3.2.0.Final/hibernate-search-parent-3.2.0.Final.pom.

You could also download the Hibernate Search distribution from Sourceforge. The distribution contains all the right dependencies as well.

Upvotes: 1

Related Questions