June 4, 2021

It’s always frustrated me that the basic list option for collections in Solr doesn’t provide any information beyond collection names.

http "https://solr.aaronwalker.dev:8983/solr/admin/collections?action=LIST"

Recently I sat down with jq (and google) to figure out how to get a collection list from Solr with basic configuration details, like the configuration name for each collection.

http "https://solr.aaronwalker.dev:8983/solr/admin/collections?action=CLUSTERSTATUS" \
| jq '.cluster.collections | to_entries | map({collection: .key , configName: .value.configName})|sort'

This code retrieves a detailed set of information on the cluster using CLUSTERSTATUS, then uses jq to extract the collection list, create an array (one object per collection) from that list and extract the collection names and configuration names, then sorts the array.

The key piece that had eluded me was the “to_entries” function in jq that transforms the collections object into an array. Searching for “jq nested objects” finally found a discussion that helped me to understand how I could extract the pieces I needed and put them together.