3
votes

First,I create a collection called usercollection:

http://xxxxx/solr/admin/collections?action=CREATE&name=usercollection&numShards=3&replicationFactor=3&maxShardsPerNode=3

Then I found something wrong, so I delete it.

 http://xxxx/solr/admin/collections?action=DELETE&name=usercollection

At last ,I want to create the collection again. And I found something wrong.

`May 16, 2013 8:32:23 PM org.apache.solr.cloud.OverseerCollectionProcessor run
 INFO: Overseer Collection Processor: Get the message id:/overseer/collection-queue-    work/qn-0000000000 message:{
"operation":"createcollection",
"numShards":"3",
"maxShardsPerNode":"3",
"createNodeSet":null,
"name":"usercollection",
"replicationFactor":"3"}
May 16, 2013 8:32:23 PM org.apache.solr.common.SolrException log
SEVERE: Collection createcollection of createcollection           failed:org.apache.solr.common.SolrException: collection already exists: usercollection
    at org.apache.solr.cloud.OverseerCollectionProcessor.createCollection(OverseerCollectionProcessor.java:311)
    at org.apache.solr.cloud.OverseerCollectionProcessor.processMessage(OverseerCollectionProcessor.java:160)
    at org.apache.solr.cloud.OverseerCollectionProcessor.run(OverseerCollectionProcessor.java:112)
    at java.lang.Thread.run(Thread.java:662)`

So, I think the collection API has something wrong when delete.Thus, how can I really delete a collection?

3
Which version of Solr do you use and what do you get at your logs when you delete collection?kamaci

3 Answers

3
votes

Had the same problem and ended up resolving by manually editing and updating clusterstate.json in zookeeper using zkcli.sh provided with Solr.

  1. Download clusterstate.json:

    zkcli.sh -z zk-host-name -cmd getfile /clusterstate.json clusterstateLoca.json

  2. Edit the downloaded clusterstateLocal.json, remove the nodes for the deleted collection, save clusterstateLocal.json locally.

  3. Remove stale clusterstate.json from ZK

    zkcli.sh -z zk-host-name -cmd clear /clusterstate.json

  4. Upload modified clusterstate.json to ZK:

    zkcli.sh -z zk-host-name -cmd putfile /clusterstate.json ./clusterstateLocal.json

2
votes

After deleting a collection you should also Commit (you can do the same without curl if using browser)

curl http://localhost:8080/solr/update -H "Content-type: text/xml" --data-binary '<commit />'

...and it is also a good idea to tell Solr to optimize it's index at this point:

curl http://localhost:8080/solr/update -H "Content-type: text/xml" --data-binary '<optimize />'

Source http://www.alphadevx.com/a/365-Clearing-a-Solr-search-index

0
votes

You need to update clusterstate.json file in your zookeeper ensemble. Your cloud collection information is kept there.