使用CollectionAdminRequest.Create from SolrJ创建集合

使用CollectionAdminRequest.Create from SolrJ创建集合,solr,solrj,solrcloud,Solr,Solrj,Solrcloud,如何在SolrJ中使用CollectionAdminRequest.Create在zookeeper运行的SolrCloud中创建新集合 我试过了 public void createIndex(String targetUuid) { HttpSolrClient solrClient = new HttpSolrClient.Builder("http://localhost:8983/solr/").build(); try {

如何在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,因为其构造函数是“受保护的”

请使用以下方法之一。您不应该再直接调用构造函数了,因为CollectionAdminRequest类上的
createCollection
方法不推荐使用构造函数

CollectionAdminRequest.Create creator = CollectionAdminRequest.createCollection("newcollection", "tg_configset", 1, 2)

这仍然会返回一个
CollectionAdminRequest.Create
对象,因此其余的代码应该可以像您期望的那样工作。

此时,我让它像
Create creator=new CollectionAdminRequest.Create一样工作(Index_Uuid,“my_configset”,1,2,0,0){/***TODO:javadoc*/private static final long serialVersionUID=-1253482406944674434L;};creator.setMaxShardsPerNode(2);creator.process(solr);
我将尝试使用它