Tara
Tara

Reputation: 549

Solr: how to delete a collection?

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?

Upvotes: 35

Views: 73460

Answers (9)

Halis Yılboğa
Halis Yılboğa

Reputation: 900

Actually I' don't understand why some body need to delete core. İf you want doing something like

http://localhost:8983/solr/core0/update?stream.body=<delete><query>*:*</query></delete>

The easiest way for deleting content of Solr core is using the code copying and pasting url above to your web browser . Please change core name accordingly. If your Solr complain for committing you can add &commit=true at the end of the url.

If you want to delete core here is code

bin/solr delete -c collection_name

Upvotes: 0

Rafal
Rafal

Reputation: 286

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.

Upvotes: 4

darkfrog
darkfrog

Reputation: 1141

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.

Upvotes: 1

Arvind Katte
Arvind Katte

Reputation: 1003

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

Upvotes: 8

iChux
iChux

Reputation: 2386

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.

Upvotes: 2

Luke Antins
Luke Antins

Reputation: 2020

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

Upvotes: 9

Gunjan
Gunjan

Reputation: 2805

Go to the solr folder and Do this..

bin/solr delete -c collection_name

and restart solr with

bin/solr restart

Upvotes: 69

Mysterion
Mysterion

Reputation: 9320

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

Upvotes: 7

Related Questions