hibernate搜索没有从远程Windows服务器数据库索引

问题描述 投票:0回答:1

我已经增加了连接的sql server远程数据库中的连接数,达到3000.当我从另一个远程Windows服务器部署一个war时,下面的hibernate搜索查询在登录后但是当我部署相同的名字时没有返回任何匹配的名称在具有数据库的Windows服务器上进行战争,hibernate搜索返回在仪表板中登录的匹配结果。这是片段

@Transactional
    public List<Books> finding(String searchTerm) { 

        org.apache.lucene.search.Query luceneQuery = qb.keyword().fuzzy().withEditDistanceUpTo(1).withPrefixLength(1).onFields("name")
                .matching(searchTerm).createQuery();

        javax.persistence.Query jpaQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, Books.class);

        List<Books> bList = null;
        try {
            jpaQuery.setMaxResults(50);
            bList = jpaQuery.getResultList();
        } catch (NoResultException nre) {
            // do nothing

        }

        return bList;
    }

我有什么遗漏让我从远程服务器获得hibernate搜索的结果

java hibernate jpa hibernate-search
1个回答
0
投票

我假设您正在使用Lucene集成(默认)而不是Elasticsearch集成。

Lucene索引存储在文件系统中,因此具有两个不同文件系统的两个服务器只使用两个不同的索引副本:一个包含索引文档,因为您在该服务器上触发了索引,另一个是空的,因为您没有。

如果您的两台服务器应该独立运行,有两个不同的数据库(如生产服务器和开发服务器),那么您只需要在两台服务器上触发重建索引。

另一方面,如果您的两台服务器应该连接,读取和写入同一数据库,那么您实际上是在运行分布式应用程序。您需要采取特定(和非平凡)步骤才能在分布式服务器之间同步索引。见this answerthis section of the reference documentation

© www.soinside.com 2019 - 2024. All rights reserved.