If you want to delete all items from Solr index, use the query
<delete><query>*:*</query></delete>
as described in the FAQ on the Solr Wiki.
But how do you actually send this query? You can use this command:
curl http://<host>:<port>/<solr_base>/update?commit=true -d '<delete><query>*:*</query></delete>'
Just replace the placeholders with the right values, e.g.
curl http://localhost:8983/solr/update?commit=true -d '<delete><query>*:*</query></delete>'
If Solr responds with something like this:
HTTP Status 400 - missing content stream Status report message missing content stream description The request sent by the client was syntactically incorrect (missing content stream).
then you are probably missing the commit parameter i.e. ?commit=true
Awesome. Saved a lot of my time. Thanks!!
If I do this, I damage the solr database or something like that? I don’t understand my friend and I need your help, there’s my e-mail, please, answer
Thank you for the hint!
Hi,
Where should i type this curl command.is that in browser? I tried in command prompt. but command prompt doesn’t identify this curl command
Hi Rajdeep!
You have to enter it on the command prompt. However, curl might not be installed on your system.
You can get it here: http://curl.haxx.se/dlwiz/?type=bin
Hope that helps!
Command Lins are
Step 1. Match all docs query in a delete by query command: *:*
curl URL=http://localhost:8080/solr3.3/update --data-binary '*:*' -H 'Content-type:text/xml; charset=utf-8'
Step 2. Send the commit command to make sure all the changes are flushed
curl http://localhost:8080/solr3.3/update --data-binary '' -H 'Content-type:text/xml; charset=utf-8'
Following is the shell script
#!/bin/sh
URL=http://localhost:8080/solr3.3/update
#match all docs query in a delete by query command: *:*
curl $URL --data-binary '*:*' -H 'Content-type:text/xml; charset=utf-8'
#send the commit command to make sure all the changes are flushed and visible
curl $URL --data-binary '' -H 'Content-type:text/xml; charset=utf-8'
echo
Command Lins are
Step 1. Match all docs query in a delete by query command: ‘*:*
curl URL=http://localhost:8080/solr3.3/update –data-binary ‘*:* -H ‘Content-type:text/xml; charset=utf-8’
Step 2. Send the commit command to make sure all the changes are flushed
curl http://localhost:8080/solr3.3/update –data-binary ” -H ‘Content-type:text/xml; charset=utf-8’
Following is the shell script
#!/bin/sh
URL=http://localhost:8080/solr3.3/update
#match all docs query in a delete by query command: *:*
curl $URL –data-binary ‘*:*’ -H ‘Content-type:text/xml; charset=utf-8’
#send the commit command to make sure all the changes are flushed and visible
curl $URL –data-binary ” -H ‘Content-type:text/xml; charset=utf-8’
echo
#!/bin/sh
URL=http://localhost:8080/solr3.3/update
It worked !!!! Thanks for saving my time.
Pingback: Restricting Solr with Jetty to localhost | Daniel Hepper
Thanks for your hint! A time saver for a very first-time Solr user like me!!
This didn’t seem to work for me… this steps here worked though: http://lunarmedia.com/Blog/2011/10/10/Solr-deleteclear-index
How do we know it worked?
run the query *:*
If it returns blank, then the index must be clean.
i want to delete all the data that has already been indexed so far…How do i do that?