Hibernate Search
  1. Hibernate Search
  2. HSEARCH-1281

Invalid code in search example - Getting Start section of documentation

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Suitable for new contributors:
      Yes, likely

      Description

      Getting Started Section: 1.5 Searching

      Example 1.9. Using Hibernate Session to create and execute search

      There is an error in the example code.
      On the line ".matching("Java Rocks!"); the ; should not be there

      FullTextSession fullTextSession = Search.getFullTextSession(session);
      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("Java rocks!");
        .createQuery();
      
      // wrap Lucene query in a org.hibernate.Query
      org.hibernate.Query hibQuery = 
          fullTextSession.createFullTextQuery(query, Book.class);
      
      // execute search
      List result = hibQuery.list();
        
      tx.commit();
      session.close();

        Activity

        Hide
        Sanne Grinovero added a comment -

        thanks! good catch

        Show
        Sanne Grinovero added a comment - thanks! good catch
        Show
        Sanne Grinovero added a comment - https://github.com/hibernate/hibernate-search/pull/386

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development