PostDao extends BaseDao<Post, Long> { public Page<Post> fullTextQuery(String queryString, QueryParser parser, Pageable pageRequest) { Query luceneQuery; try { luceneQuery = parser.parse(queryString); } catch (ParseException e) { throw new ServiceException(e); } FullTextSession s = Search.getFullTextSession(getSession()); FullTextQuery query = s.createFullTextQuery(luceneQuery, Post.class); query.setMaxResults(pageRequest.getPageSize()); query.setFirstResult(pageRequest.getOffset()); @SuppressWarnings("unchecked") List<Post> result = query.list(); PageImpl<Post> page = new PageImpl<Post>(result, pageRequest, query.getResultSize()); return page; }  Page<Post> fullTextQuery(String queryString, QueryParser parser,
			Pageable pageRequest); List<Post> fullTextQuery(String queryString, QueryParser parser);  }
@Test public void testFullTextQueryStringQueryParserPageable() { Page<Post> result = postDao.fullTextQuery("content:first", new QueryParser(Version.LUCENE_35, "content", new StopAnalyzer( Version.LUCENE_35)), new PageRequest(0, 10)); List<Post> list = result.getContent(); assertThat(list.size(), equalTo(2)); }
@Test public void testFullTextQueryStringQueryParser() { List<Post> list = postDao.fullTextQuery("content:first", new QueryParser(Version.LUCENE_35, "content", new StopAnalyzer( Version.LUCENE_35))); assertThat(list.size(), equalTo(2)); }