Solr Cheatsheet

To get the cluster status

curl --negotiate -u : "http://$(hostname -f):8886/solr/admin/collections?action=clusterstatus&wt=json&indent=true" | python -m json.tool

To list contains of the solr collection

curl -ikv --negotiate -u: "http://$(hostname -f):8886/solr/vertex_index/select?q=*%3A*&wt=json&rows=10&indent=true"
curl -ikv --negotiate -u: "http://$(hostname -f):8886/solr/fulltext_index/select?q=*%3A*&wt=json&rows=10&indent=true"
curl -ikv --negotiate -u: "http://$(hostname -f):8886/solr/edge_index/select?q=*%3A*&wt=json&rows=10&indent=true"

To delete solr collection

curl -iv --negotiate -u: "http://<solr>:8886/solr/admin/collections?action=DELETE&name=<collection_name>&async=<collection_name>"

To check the solr data directory


To create new solr collection

curl -iv --negotiate -u: 'http://<AMBARI_INFRA_SOLR_FQDN>:8886/solr/admin/collections?action=create&name=ranger_audits&numShards=1&replicationFactor=1&collection.configName=ranger_audits' 

To make shard as active leader

curl -k --negotiate -u : "http://$(hostname -f):8886/solr/admin/collections?action=FORCELEADER&collection=ranger_audits?shard=shard1"

Note: This command can take 15 to 20 seconds to return the output

Known Issues

Expected log message when solr collection is down

GSSException: Failure unspecified at GSS-API level (Mechanism level: Request is a replay (34))

You will get 404 not found error for collection if you have below property set

If documents in the solr collection are higher than 2 billion then to reduce the retention of solr collection you can run below command

curl --negotiate -u: "http://$SOLR_HOST:8886/solr/ranger_audits/update?commit=true" -H "Content-Type:text/xml" --data-binary "<delete><query>evtTime:[* TO NOW-15DAYS]</query></delete>" 

Steps to upgrade Solr instance to Solr 7

Ambari upgraded to 2.7 and Infra Solr was restarted mistakenly

1. $ kinit -kt <infra-solr-keytab> <principal>
$ /usr/hdp/current/zookeeper-client/bin/ -server `hostname -f` get /infra-solr/security.json > /var/tmp/security.json

2) Disable the authorization by replacing the following in infra-solr-env in Ambari:Replace:

3) If ambari version is at least 2.7.1, replace logj4 props as well in infra-solr-envReplace:

4) In Infra-Solr Config-> Advanced infra-solr-security-json,
Select "Manually Managed"

5) Update security.json with the below content:/usr/hdp/current/zookeeper-client/bin/ -server `hostname -f` set /infra-solr/security.json "{ "authentication": { "class": "" } }"

Please note that these should be reverted after the solr instances are upgraded.
# Restart infra-solr.
# Back up Ambari Infra Solr Data
# Remove Existing Collections & Upgrade Binaries

Leave a Comment