V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tomoya92
V2EX  ›  Java

请问 hibernate search 怎么手动创建索引

  •  
  •   tomoya92 · 2016-07-09 08:06:12 +08:00 · 2942 次点击
    这是一个创建于 2867 天前的主题,其中的信息可能已经有所发展或是发生改变。
    FullTextSession fullTextSession = Search.getFullTextSession(session);
    fullTextSession.createIndexer().startAndWait();
    
    //or
    
    EntityManager em = entityManagerFactory.createEntityManager();
    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
    fullTextEntityManager.createIndexer().startAndWait();
    

    这种方式是将表内的所有数据都给索引了,如果数据量大的话,会非常的慢

    我想根据某些条件查询出表内的一些数据,然后进行索引,百度没找到好答案,请问 v 站大大们,这个该怎么处理呢?

    1 条回复    2016-07-09 08:29:24 +08:00
    tomoya92
        1
    tomoya92  
    OP
       2016-07-09 08:29:24 +08:00   ❤️ 1
    我解决了
    ```
    FullTextSession fullTextSession = Search.getFullTextSession(sessionFactory.getCurrentSession());
    fullTextSession.index(Entity);
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1033 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:25 · PVG 04:25 · LAX 13:25 · JFK 16:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.