• Home
  • Docker
  • Kubernetes
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • CI
  • Install
  • Samples
  • Archived
Apache Solr | create_collection command
  1. Notes
  2. create_collection command help
  3. Create a collection using an existing Solr configuration in ZooKeeper
  4. Create a collection + using/uploading to ZooKeeper the default Solr configuration
  5. Create a collection + uploading to ZooKeeper a custom Solr configuration (configuration directory)
  6. Create a collection + uploading to ZooKeeper a custom Solr configuration (custom path)
  7. Create a collection + uploading to ZooKeeper the default Solr configuration + overriding the default name of the Solr configuration in ZooKeeper
  8. Create a collection with 2 shards and 2 replicas (copies)

  1. Notes
    See this page for more details on how to upload Solr configuration to ZooKeeper: Uploading Solr configuration in ZooKeeper

    See this page for more details on how to Install and configure a Solr Cluster: SolrCloud: Cluster

  2. create_collection command help
  3. Create a collection using an existing Solr configuration in ZooKeeper
    Create the collection:

    Output:

    Notes:
    • If the configuration "solr_config1" doesn't exist (it wasn't created/uploaded to ZooKeeper), Solr will then try to create a new configuration with the name "solr_config1" by using the configuration "_default". You will get the following output:

      Note that even if the collection will use an existing Solr configuration in ZooKeeper, the "${SOLR_HOME}/configsets/_default" directory must exist, otherwise you will get this error: Specified configuration directory _default not found!

    • You can verify that the collection was created in ZooKeeper:
  4. Create a collection + using/uploading to ZooKeeper the default Solr configuration
    If you don't specify a Solr configuration when creating a collection, Solr will create a new configuration with the name of the collection.
    Solr will use the default configuration "_default" ("${SOLR_HOME}/configsets/_default").

    Create the collection:

    Output:

    Notes:
    You can verify that the configuration "collection2" is created in ZooKeeper:

    You can verify that the collection "collection2" is created in ZooKeeper:
  5. Create a collection + uploading to ZooKeeper a custom Solr configuration (configuration directory)
    You can create a collection and specify a name of a Solr configuration directory (using the parameter "-d DIRECTORY_NAME") that will be used to create and upload the Solr configuration to ZooKeeper.

    You can choose one of the following directories names that can be found under (${SOLR_HOME}/configsets/):
    ► _default
    ► sample_techproducts_configs

    The name of the new configuration in ZooKeeper will be the same name of the created collection: "collection3"

    Create the collection:

    Output:
  6. Create a collection + uploading to ZooKeeper a custom Solr configuration (custom path)
    You can create a collection and specify a path of a Solr configuration directory (using the parameter "-d DIRECTORY_PATH") that will be used to create and upload the Solr configuration to ZooKeeper.

    Solr will try to find the Solr configuration files in the provided directory "DIRECTORY_PATH/".
    If not found, Solr will look at the "conf/" folder under the provided directory "DIRECTORY_PATH/conf/".
    If not found, Solr will look at the "server/solr/configsets/conf/" folder under the provided directory "DIRECTORY_PATH/server/solr/configsets/conf/".

    The name of the new configuration in ZooKeeper will be the same name of the created collection: "collection4"

    Create the collection:

    Output:
  7. Create a collection + uploading to ZooKeeper the default Solr configuration + overriding the default name of the Solr configuration in ZooKeeper
    Create the collection:

    Output:
  8. Create a collection with 2 shards and 2 replicas (copies)
    You need to have 2 Solr instances (up and running)

    Create the collection:

    Output:

    Solr - collections:
    Apache Solr/create_collection

    Notes:

    • A znode "/solr/collections/collection6" (Solr collection) will be creacted in ZooKeeper and will contain the following znodes:

    • The znode "/solr/configs/solr_config1" (Solr configuration) contain the following znodes:

    • The shards/replicas of the collection will be created in the file system:


    • See more details in these files:
      ► ${SOLR_ROOT_INSTANCE_1}/server/solr/collection6_shard1_replica_n2/core.properties
      ► ${SOLR_ROOT_INSTANCE_1}/server/solr/collection6_shard2_replica_n6/core.properties

      ► ${SOLR_ROOT_INSTANCE_2}/server/solr/collection6_shard1_replica_n1/core.properties
      ► ${SOLR_ROOT_INSTANCE_2}/server/solr/collection6_shard2_replica_n4/core.properties

© 2025  mtitek