I'd like to delete all of the indexed data in my Solr collection, preferably via a shell command on one of the nodes itself. How can I do that?
Asked
Active
Viewed 5,501 times
2 Answers
5
If you have access to the shell, use the solrctl
command with the following options:
solrctl collection --deletedocs <collection-name>
Here's the full usage output from solrctl --help
for reference:
usage: /usr/bin/solrctl [options] command [command-arg] [command [command-arg]] ...
Options:
--solr solr_uri
--zk zk_ensemble
--help
--quiet
Commands:
init [--force]
instancedir [--generate path]
[--create name path]
[--update name path]
[--get name path]
[--delete name]
[--list]
collection [--create name -s <numShards>
[-c <collection.configName>]
[-r <replicationFactor>]
[-m <maxShardsPerNode>]
[-n <createNodeSet>]]
[--delete name]
[--reload name]
[--stat name]
[--deletedocs name]
[--list]
core [--create name [-p name=value]...]
[--reload name]
[--unload name]
[--status name]
If you don't have direct access, you can use Solr's update services as described here, here, and here.
-
We are using CDH 5.1.3 and I'm using the solrctl utility to deletedocs in my collection. following is the command `solrctl --zk ${ZKHOST} collection --deletedocs ${COLLECTIONNAME}`. The collection is empty. when I looked at /solr/
/core_ – venBigData Dec 31 '14 at 21:35/data/index I see that I have _1.fdt, _1.fdx etc and _2.fdt, _2.fdx etc. seems like a bug to me or I'm missing something -
That's definitely odd. I know it worked for me in CDH 4.2 and CDH 4.7. We're in the process of upgrading to CDH 5.3 right now. I'll add another comment as to whether it works in that version once I can test it out. – jstricker Jan 01 '15 at 03:20
0
you can use below command for command prompt
curl http://<ip_address>:8983/solr/<collection_name>/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8';

Bhuvan
- 104
- 9