-2

I have already integrate Spring MVC+ Spring Framework 4 + Hibernate ORM 4.

Now I want to use full text search in hibernate search.

So, How to Integrate Spring Framework 4 with Hibernate Search 5?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Robin Han
  • 101
  • 7

1 Answers1

3

According to the official documentation this should be as simple as:

  1. Add Hibernate Search JAR to the application.
  2. Add <property name="hibernate.search.default.directory_provider" value="filesystem"/> and <property name="hibernate.search.default.indexBase" value="/var/lucene/indexes"/> to the Hibernate configuration. Alternatively, you can choose a different provider.
  3. Annotate the entities and fields you want to index.
  4. If using the Hibernate Session directly, obtain a FullTextSession as Search.getFullTextSession(sessionFactory.getCurrentSession()), or if using an EntityManager, obtain a FullTextEntityManager as Search.getFullTextEntityManager(entityManager). It is assumed that sessionFactory or entityManager is injected using Spring.
  5. Start searching. Entity instances are automatically indexed on persist so no special steps are required for generating the search indexes.

Give this a try and if you face any specific problem you can raise them as separate questions.

manish
  • 19,695
  • 5
  • 67
  • 91
  • Thanks for your solution.But I have a problem "**SearchException: HSEARCH000103: Unable to initialize IndexManager**" after adding **@Indexed** to my entities. – Robin Han Mar 08 '15 at 16:17