我在Spring Boot中使用Hibernate Search。我没有对Hibernate Search进行任何特殊配置。它仅显示应用程序启动时的警告。如何指定hibernate.search.lucene_version?我的SearchService类(使用Hibernate Search的唯一位置):@Servicepublic class SearchService { private FullTextEntityManager fullTextEntityManager; private QueryBuilder queryBuilder; @Autowired public SearchService(EntityManager entityManager) { entityManager = entityManager.getEntityManagerFactory().createEntityManager(); fullTextEntityManager = Search.getFullTextEntityManager(entityManager); } @PostConstruct public void initialize() throws InterruptedException { fullTextEntityManager.createIndexer().startAndWait(); queryBuilder = fullTextEntityManager.getSearchFactory() .buildQueryBuilder().forEntity(Post.class).get(); } public List<Post> searchByQuery(String query) { org.apache.lucene.search.Query luceneQuery = queryBuilder.phrase() .withSlop(5) .onField("title") .sentence(query) .createQuery(); Query jpaQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, Post.class); return (List<Post>) jpaQuery.setMaxResults(20).getResultList(); }}
添加回答
举报
0/150
提交
取消