未指定hibernate.search.lucene_version:

我在Spring Boot中使用Hibernate Search。我没有对Hibernate Search进行任何特殊配置。它仅显示应用程序启动时的警告。如何指定hibernate.search.lucene_version?


我的SearchService类(使用Hibernate Search的唯一位置):


@Service

public 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();

    }

}


蓝山帝景
浏览 186回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java