Howto clear Solr index

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

15 thoughts on “Howto clear Solr index

  1. 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

  2. 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

  3. 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

  4. 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

  5. #!/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
    
    
  6. Pingback: Restricting Solr with Jetty to localhost | Daniel Hepper

  7. i want to delete all the data that has already been indexed so far…How do i do that?