我在查询构建器中遇到错误,无法输入,并且找不到 org.apache.lucene 。
我将添加与spring-mvc和hibernate相关的所有jar
@Repository
public class SearchDAO {
@Autowired
SessionFactory sessionFactory;
@Transactional
public List<SearchVO> viewSeachResult(String searchText) throws Exception
{
try
{
Session s= this.sessionFactory.openSession();
//Session s= HibernateUtil.getSession();
FullTextSession text = Search.getFullTextSession(s);
// create native Lucene query unsing the query DSL
// alternatively you can write the Lucene query using the Lucenquery
// parser
// or the Lucene programmatic API. The Hibernate Search DSL is
// recommended though
QueryBuilder qb = text.getSearchFactory().buildQueryBuilder().forEntity(SearchVO.class).get();
org.apache.lucene.search.Query query= qb.keyWord().onFields("Description","Title","Author","Area").matching(searchText).createQuery();
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query,SearchVO.class);
List<SearchVO> result= hibQuery.list();
return result;
}catch(Exception e)
{
throw e;
}
}
}
答案 0 :(得分:1)
我认为你需要hibernate-search jar。
提到所需的罐子here。
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>5.3.0.Final</version>
</dependency>
您可以从here手动下载。
希望这有帮助。