如何在SolrJ中使用CollectionAdminRequest.Create在以Zookeeper运行的SolrCloud中创建一个新集合。
我尝试过
public void createIndex(String targetUuid) {
HttpSolrClient solrClient = new HttpSolrClient.Builder("http://localhost:8983/solr/").build();
try {
// 1. Create Index with two shards and one replicas
if(uploadConfigset()) {
//Error Here
CollectionAdminRequest.Create creator = new CollectionAdminRequest.Create(targetUuid,"tg_configset",1,2,0,0);
creator.setMaxShardsPerNode(2);
creator.process(solrClient);
}
} catch (IOException | SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
但是不能使用CollectionAdminRequest.Create,因为其构造函数受“保护”
答案 0 :(得分:1)
使用CollectionAdminRequest.createCollection方法之一。您不应该再直接调用该构造函数,因为CollectionAdminRequest类的createCollection
方法已弃用该构造函数。
CollectionAdminRequest.Create creator = CollectionAdminRequest.createCollection("newcollection", "tg_configset", 1, 2)
这仍然返回CollectionAdminRequest.Create
对象,因此其余代码应按预期工作。