Utilisation de l'API SOLR
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.
Créer une collection SOLR
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"
Supprimer une collection SOLR
Pour supprimer une collection, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=DELETE&name=collection_test"
Lister les collections SOLR
Pour lister les collections, tapez la commande suivante:
curl --negotiate -u : "http://localhost:8983/solr/admin/collections?action=LIST&wt=json"
Recharger une collection SOLR
Pour recharger une collection, tapez la commande suivante:
curl -v --negotiate -u : "http://localhost:8983/solr/admin/collections?action=RELOAD&name=collection_test"
Créer un alias d'une collection SOLR
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"
Supprimer un alias d'une collection SOLR
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"
Connaître le nombre de documents d'une collection SOLR
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.
Supprimer le contenu d'une collection SOLR
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.