Yêu cầu thg 7 12, 2021 9:06 SA 41 1 0
  • 41 1 0
+1

Câu hỏi: Cách connect mutilple connect server solr in spring-data-solr

Chia sẻ
  • 41 1 0

Hiện tại mình muốn tạo kết nối đến server solr thì có cách nào không ạ. Hiện tại code của em như sau:

Connect server solr 1

@Configuration @EnableSolrRepositories(basePackages={"foo.utilities.solr.repos.gcr"}, multicoreSupport=true) public class GcrSolrContext {

@Bean
public SolrClient solrClient() {
    return new HttpSolrClient("http://foo:8086/solr/gcr");
}

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

}

Connect server solr 2

@Configuration @EnableSolrRepositories(basePackages={"foo.utilities.solr.repos.different"}, multicoreSupport=true) public class DifferentSolrContext {

@Bean
public SolrClient solrClient() {
    return new HttpSolrClient("http://SomethingDifferent:8086/solr/something");
}

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

}

Yêu cầu giả sử có một cái pull down: sever solr1, sever solr2. khi thực hiện chọn cái nào thi connect đến server solr đó.

Em code như trên bị lỗi là server solr1 bị server solr 2 đè. Mọi ngươif giúp em config đoạn ni với ạ.

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí