繁体   English   中英

在运行时创建新的 SOLR 集合

[英]Create new SOLR collection at runtime

我正在使用带有 JAVA spring boot 应用程序的 SOLR 7.1.0 服务器。 为了与 SOLR 服务器通信,我使用了“springframework.data.solr”,我有一个“模板”模式,我想在运行时从中创建新的核心。

我想要实现的目标是为每个客户创建一个新的核心,同时保持架构相同。

这是我的 SolrConfig 的样子:

@Configuration
@EnableSolrRepositories(basePackages = "com.my.repository", multicoreSupport = true)
@ComponentScan
public class SolrConfig {

    @Bean
    public SolrClient solrClient() {
        return new HttpSolrClient("http://localhost:8983/solr");
    }

    @Bean
    @Scope("prototype")
    public SolrTemplate solrTemplate(SolrClient client) throws Exception {
        return new SolrTemplate(client);
    }
}

我的存储库界面:

public interface OpenItemsDebtorsRepository extends CustomOpenItemsDebtorsRepository, SolrCrudRepository<OpenItemDebtor, String> {
    void setCore(String core);

    @Query("orderNumber:*?0*~")
    List<OpenItemDebtor> findByOrderNumber(String orderNumber);
}

我正在寻找这样的东西:

solrTemplate.CreateNewCore(String coreName)

你有什么建议吗?

我强烈建议您在 Spring Boot 项目中使用本机 Solr 客户端 (SolrJ)。 创建一个服务组件,该组件将为您提供 Solr 服务器 (CLoudSolrClient) 的实例。

SolrJ 拥有创建和管理核心和集合所需的所有组件。

我知道这不是一个直接的答案,但我希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM