title: Hibernate Full Text Search
body: <p>I was just created a hibernate full text search using hibernate-search-4.1.1.Final.jar and all runtime dependencies.
  There is no errors in this application.
  But my Lucene query unsing the query DSL doesn't return any results.
  I mean doesn't return any of rows in the table.
  can any one please help me.</p>
  
  <p>Main Search program
      This Java code is used to perform hibernate full text search.</p>
  
  <pre><code>   public class MainSearch {
                  public static void main(String args[]) {
              Iterator iterator;
              Session session = HibernateUtil.getSession();
              // FullTextSession fullTextSession = Search.getFullTextSession(session);
  
              FullTextSession fullTextSession = Search.getFullTextSession(session);
              org.hibernate.Transaction tx = fullTextSession.beginTransaction();
  
              // create native Lucene query unsing the query DSL
              // alternatively you can write the Lucene query using the Lucene query
              // parser
              // or the Lucene programmatic API. The Hibernate Search DSL is
              // recommended though
              QueryBuilder qb = fullTextSession.getSearchFactory()
                      .buildQueryBuilder().forEntity(Book.class).get();
              org.apache.lucene.search.Query query = qb.keyword()
                      .onFields("title", "subtitle", "authors.name").matching("cpp")
                      .createQuery();
  
              // wrap Lucene query in a org.hibernate.Query
              org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(
                      query, Book.class);
  
              // execute search
  
              List result = hibQuery.list();
              iterator = result.iterator();
              while (iterator.hasNext()) {
                  System.out.print(iterator.next() + " ");
              }
              System.out.println();
              // Check list empty or not
              if (result.isEmpty()) {
                  System.out.println("Linked list is empty");
              }
  
              tx.commit();
              session.close();
          }
      }
  </code></pre>