Skip to content

Instantly share code, notes, and snippets.

@nz
Last active November 13, 2024 01:24
Show Gist options
  • Save nz/673027 to your computer and use it in GitHub Desktop.
Save nz/673027 to your computer and use it in GitHub Desktop.
Delete all documents in a Solr index using curl
# http://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F
# http://wiki.apache.org/solr/UpdateXmlMessages#Updating_a_Data_Record_via_curl

curl "http://index.websolr.com/solr/a0b1c2d3/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'

I'm amused at the traction this little gist is getting on Google! I would be remiss not to point out that six+ years later I'm still helping thousands of companies on a daily basis with their search index management, by providing managed Solr as a service over at Websolr, and hosted Elasticsearch at Bonsai. Check us out if you'd like an expert helping hand at Solr and Elasticsearch hosting, ops and support!

@jeffrycopps
Copy link

Fire this in the browser
For deletion:
http://host:port/solr/core/update?stream.body=:&commit=true
For schema reload:
http://host:port/solr/admin/cores?action=RELOAD&core=core
Replace
host: Host name
port: Port number
core: Core Name

@SainathSharmadha
Copy link

SainathSharmadha commented Aug 23, 2016

Through curl :

curl http://host:port/solr/core_name/update?commit=true -H "Content-Type: text/xml" --data-binary `'<delete><query>*:*</query></delete>'`

Through browser :

http://host:port/solr/core_name/update?commit=true&stream.body=<delete><query>*:*</query></delete>

@qiqidone
Copy link

single core:
curl http://localhost:8080/solr/update?commit=true -H "Content-Type: text/xml" --data-binary ':'
multiple core:
curl http://localhost:8080/solr/core_name/update?commit=true -H "Content-Type: text/xml" --data-binary ':'

@objectivePinta
Copy link

objectivePinta commented Dec 2, 2016

@GrazingScientist
Copy link

GrazingScientist commented Jan 17, 2018

The command by objectivePinta is shut off at least in Solr version 7.2.0 (in the out of the box configuration). However, the curl - solution of SainathSharmadha worked (for me) in this version.

@captainjackrana
Copy link

captainjackrana commented Feb 9, 2018

Solr version 7.2.0 doesn't allow stream body anymore.
However, SainathSharmadha code will work by using binary data type.
If you're using the Post tool provided by solr:
bin/post -c core_name -type text/xml -out yes -d $'<delete><query>*:*</query></delete>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment