2

How can I use CollectionAdminRequest.Create in SolrJ to create a new collection in SolrCloud running with zookeeper.

I tried

    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();
            }

        }

But can not use CollectionAdminRequest.Create as its constructor is 'protected'

1 Answer 1

3

Use one of the CollectionAdminRequest.createCollection methods. You're not supposed to call the constructor directly any longer, as it has been deprecated for the createCollection methods on the CollectionAdminRequest class.

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

This still returns a CollectionAdminRequest.Create object, so the rest of the code should work as you'd expect.

Sign up to request clarification or add additional context in comments.

2 Comments

At the moment I made it work like 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);
I will try it wil CollectionAdminRequest.createCollection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.