35

I am using solr 4.9, not adding any additional shard, just use whatever default it comes with it. I have created a collection and tried to delete it by using the following api :

http://<host>/solr/admin/collections?action=DELETE&name=collectionName

but it returns error :

Solr instance is not running in SolrCloud mode

My Solr is not solrCloud, but how do I delete my collection?

Shawn Mehan
  • 4,513
  • 9
  • 31
  • 51
Tara
  • 549
  • 2
  • 7
  • 14

8 Answers8

68

Go to the solr folder and Do this..

bin/solr delete -c collection_name

and restart solr with

bin/solr restart
Gunjan
  • 2,775
  • 27
  • 30
9

n.b. Tested against Solr 4.9, should work with newer versions.

curl -v http://localhost:8983/solr/admin/cores?action=UNLOAD&deleteInstanceDir=true&core=collectionName
Luke Antins
  • 2,010
  • 1
  • 19
  • 15
8

You can delete the Solr Collection in two ways.

1) From the command prompt:

Launch the command prompt from where you have extracted the Apache Solr. Run the below Command

Solr\bin>solr delete -c My_Collection

2) From the Solr Admin Console:

/admin/collections?action=DELETE&name=collection

For more information about the Apache Solr Collection API. Apache Solr Collection API

Arvind Katte
  • 995
  • 2
  • 10
  • 20
7

According to this guide (https://cwiki.apache.org/confluence/display/solr/Collections+API) this API is working only, when you are in a SolrCloud mode.

If you want to just delete core or just delete all docs in that core, take a look here - https://wiki.apache.org/solr/CoreAdmin

Mysterion
  • 9,050
  • 3
  • 30
  • 52
4

You can delete a collection in three ways in the recent versions of Solr.

  1. You can delete the collection manually by using the bin/solr tool
  2. You can delete the collection manually via Solr Admin
  3. You can delete the collection by using the Collections API
  4. You can delete the collection by using the V2 API

Deleting a collection using the bin/solr tool is simple. You go to your SOLR_HOME directory and you run:

bin/solr delete -c COLLECTION_NAME

To delete a collection using the Collections API you would run a command like this:

curl 'localhost:8983/solr/admin/collections?action=DELETE&name=COLLECTION_NAME'

Finally, to use the V2 API and delete a collection using it you would do the following:

curl -XDELETE 'http://localhost:8983/api/c/COLLECTION_NAME'

If you plan on removing the collection very rarely, you can do that manually. If that is something commonly used - for example with aliases and time-based data I would suggest using the V2 API as this is the newest one and will probably replace the old APIs at some point.

Rafal
  • 216
  • 1
  • 5
2

You could use curl

curl -X GET -H "Content-Type: application/json" "http://localhost:8983/solr/admin/cores?wt=json&action=UNLOAD&core=gettingstarted"

Where gettingstarted is the name of the core that you want to delete. Please note that the above assumes that solr is running on port 8983.

iChux
  • 2,266
  • 22
  • 37
1

Though Adam's response is correct, here's the documentation to help use it: https://lucene.apache.org/solr/guide/7_7/collections-api.html#delete

I got stuck on this one for a while and was only getting the invalid deleting of cores answer, which, I'm guessing used to work for collections, but does not in newer versions.

darkfrog
  • 1,053
  • 8
  • 29