Hibernate搜索索引现有数据

时间:2014-06-19 10:49:36

标签: java hibernate lucene hibernate-search

我正在使用Hibernate Search 4.4.2 Final for my Application。添加新数据时。它被立即索引,但是,我需要全文搜索来处理旧实体。如何使用多个租户重新索引现有数据?我已经尝试过查看文档,但是这篇文章不知道索引数据。

代码成功运行,没有错误但是当我通过Luke检查索引时。没有找到现有的索引/数据。我这样做是对的吗?顺便说一下,我使用PostgresSQL作为我的数据库,具有多租户

在我的控制器中

@Override
    @RequestMapping(value = RELOAD_URL, method = RequestMethod.GET, produces="application/json")
    @ResponseBody
    public String reloadIndex() {
        patientService.reloadIndex();
        return "OK";
    }

在我的patientService

@Override
    @Transactional
    public void reloadIndex() {
        patientRepo.reloadIndex();
    }

在我的patientRepo.reloadIndex

FullTextEntityManager fullTextEntityManager = 
                    Search.getFullTextEntityManager(entityManager);

    try {

       fullTextEntityManager.createIndexer().startAndWait();
    } catch (InterruptedException e) {
       // Exception handling
         e.printStackTrace()
    }

0 个答案:

没有答案