Eli Johnes
Eli Johnes

Reputation: 351

curl command to get shard information of a solr collection

Please let me know if there is a curl command which would give us the shard information of a given collection in solr. That is, information about how many shards the given collection is split into and its replication factor. I understand that it can be seen through solr admin UI. But, we are looking for the curl command which would yield the same result.

Upvotes: 0

Views: 1115

Answers (1)

MatsLindh
MatsLindh

Reputation: 52892

The Admin UI is a Javascript application. If you look in your browser's development tools under the "Networking" tab you'll see exactly which requests the UI are making to display the required information. You can then use the same endpoint in curl to retrieve the same information and process it according to your wishes.

The CLUSTERSTATUS endpoint will give you the information you're looking for:

http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS
{
  "responseHeader":{
    "status":0,
    "QTime":333},
  "cluster":{
    "collections":{
      "collection1":{
        "shards":{
          "shard1":{
            "range":"80000000-ffffffff",
            "state":"active",
            "health": "GREEN",
            "replicas":{
              "core_node1":{
                "state":"active",
                "core":"collection1",
                "node_name":"127.0.1.1:8983_solr",
                "base_url":"http://127.0.1.1:8983/solr",
                "leader":"true"},
              "core_node3":{
                "state":"active",
                "core":"collection1",
                "node_name":"127.0.1.1:8900_solr",
                "base_url":"http://127.0.1.1:8900/solr"}}},
          "shard2":{
            "range":"0-7fffffff",
            "state":"active",
            "health": "GREEN",
            "replicas":{
              "core_node2":{
                "state":"active",
                "core":"collection1",
                "node_name":"127.0.1.1:7574_solr",
                "base_url":"http://127.0.1.1:7574/solr",
                "leader":"true"},
              "core_node4":{
                "state":"active",
                "core":"collection1",
                "node_name":"127.0.1.1:7500_solr",
                "base_url":"http://127.0.1.1:7500/solr"}}}},
        "maxShardsPerNode":"1",
        "router":{"name":"compositeId"},
        "replicationFactor":"1",
        "znodeVersion": 11,
        "autoCreated":"true",
        "configName" : "my_config",
        "health": "GREEN",
        "aliases":["both_collections"]
      },
      "collection2":{
        "..."
      }
    },
    "aliases":{ "both_collections":"collection1,collection2" },
    "roles":{
      "overseer":[
        "127.0.1.1:8983_solr",
        "127.0.1.1:7574_solr"]
    },
    "live_nodes":[
      "127.0.1.1:7574_solr",
      "127.0.1.1:7500_solr",
      "127.0.1.1:8983_solr",
      "127.0.1.1:8900_solr"]
  }
}

Upvotes: 1

Related Questions