I believe you may be missing a createQuery()
at the end, but otherwise, looks reasonable enough to me, but you can always check for yourself. Once you have created the final query, just use the Query.toString()
method, which should give you a human readable representation of the query, provided you are reasonably familiar with Lucene query parser syntax. Like:
QueryBuilder qb = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(User.class).get();
Query query = qb.bool()
.should(qb.keyword().onField("name").matching(searchQuery).createQuery())
.should(qb.keyword().fuzzy().withPrefixLength(1).onField("name").matching(searchQuery).createQuery())
.createQuery();
System.out.println(query.toString())
//Or however you like to output debugging information...