Chaque action sur SOLR peux se faire soit via l'interface d'administration HTTP, soit par l'API en curl. Néanmoins, l'interface d'administration s'est avérée peux efficaces pour gérer SOLR, c'est pourquoi bon nombres d'actions se font via l'API.
Pour créer une collection de 4 shards et un réplica pour chaque shard, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=CREATE&name=collection_test&num_shards=4&maxShardsPerNode=2&collection.configName=collection_test&replicationFactor=2"
Pour supprimer une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=DELETE&name=collection_test"
Pour lister les collections, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=LIST&wt=json"
Pour recharger une collection, tapez la commande suivante:
curl -v --negotiate -u : "http://localhost:8983/solr/admin/collections?action=RELOAD&name=collection_test"
Pour créer un alias d'une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=CREATEALIAS&name=collection_test&collections=collection_test1,collection_test2"
Pour supprimer un alias d'une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=DELETEALIAS&name=collection_test"
Pour connaître le nombre de documents d'une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/collection_test/select?q=*&rows=0"
Note:
Cette commande est valable également pour un Alias.
Important:
Il s'agit ici de supprimer tout le contenu d'une collection. La collection existera toujours.
Pour supprimer le contenu d'une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/collection_test/update?commit=true&stream.body=<delete><query>*:*</query></delete>"
Note:
Cette commande est valable également pour un Alias.