private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); // Ideally this property used so a new configset is not uploaded for every single // index (collection) created in solr. // if a generic configSet is not set, make the configset name the same as the collection. // This was the default behavior before a default configSet could be specified String genericConfigSet = config.has(SOLR_DEFAULT_CONFIG) ? config.get(SOLR_DEFAULT_CONFIG):collection; CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(genericConfigSet); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); collectionName = collectionName.split(",")[0]; if (!collectionNames.contains(collectionName)) { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary); collectionName = collectionName.split(",")[0]; if (!collectionNames.contains(collectionName)) { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(solrCloudNumShards) .setConfigName(solrCloudConfigName).process(primary);
protected void createCollectionIfNotExist(CloudSolrClient client, String collectionName) { Set<String> collectionNames = client.getZkStateReader().getClusterState().getCollections(); if (!collectionNames.contains(collectionName)) { try { new CollectionAdminRequest.Create().setCollectionName(collectionName).setNumShards(getSolrCloudNumShards()) .setMaxShardsPerNode(getSolrCloudNumShards()).setConfigName(getSolrCloudConfigName()).process(client); } catch (SolrServerException e) { throw ExceptionHelper.refineException(e); } catch (IOException e) { throw ExceptionHelper.refineException(e); } } }
.setReplicationFactor(remoteSolrServerConfiguration.getSolrReplicationFactor()) .setConfigName(solrCollection) .setNumShards(remoteSolrServerConfiguration.getSolrShardsNo()) .process(cloudSolrServer);
.setReplicationFactor(remoteSolrServerConfiguration.getSolrReplicationFactor()) .setConfigName(solrCollection) .setNumShards(remoteSolrServerConfiguration.getSolrShardsNo()) .process(cloudSolrServer);
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(collection); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
private static void createCollectionIfNotExists(CloudSolrClient client, Configuration config, String collection) throws IOException, SolrServerException, KeeperException, InterruptedException { if (!checkIfCollectionExists(client, collection)) { Integer numShards = config.get(NUM_SHARDS); Integer maxShardsPerNode = config.get(MAX_SHARDS_PER_NODE); Integer replicationFactor = config.get(REPLICATION_FACTOR); CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setConfigName(collection); createRequest.setCollectionName(collection); createRequest.setNumShards(numShards); createRequest.setMaxShardsPerNode(maxShardsPerNode); createRequest.setReplicationFactor(replicationFactor); CollectionAdminResponse createResponse = createRequest.process(client); if (createResponse.isSuccess()) { logger.trace("Collection {} successfully created.", collection); } else { throw new SolrServerException(Joiner.on("\n").join(createResponse.getErrorMessages())); } } waitForRecoveriesToFinish(client, collection); }
static void createCollection( String collection, int numShards, int replicationFactor, AuthorizedSolrClient client) throws Exception { CollectionAdminRequest.Create create = new CollectionAdminRequest.Create() .setCollectionName(collection) .setNumShards(numShards) .setReplicationFactor(replicationFactor) .setMaxShardsPerNode(2); client.process(create); }
protected void createCloudCollection(String name, int numShards) throws IOException, SolrServerException { CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create(); createRequest.setCollectionName(name); createRequest.setNumShards(numShards); createRequest.process(getClient()); }