Deleting solr documents from Solr Admin

Use one of the queries below in the Document tab of Solr Admin UI:

XML:

<delete><query>*:*</query></delete>

JSON:

{'delete': {'query': '*:*'}}

Make sure to select the Document Type drop down to Solr Command (raw XML or JSON).


Update: newer versions of Solr may work better with this answer: https://stackoverflow.com/a/48007194/3692256

My original answer is below:


I'm cheating a little, but not as much as writing the query by hand.

Since I've experienced the pain of accidental deletions before, I try to foolproof my deletions as much as possible (in any kind of data store).

1) Run a query in the Solr Admin Query screen, by only using the "q" parameter at the top left. Narrow it to the items you actually want to delete. For this example, I'm using *:*, but you can use things like id:abcdef or a range or whatever. If you have a crazy complex query, you may find it easier to do this multiple times, once for each part of the data you wish to delete.

2) On top of the results, there is a grayed out URL. If you hover the mouse over it, it turns black. This is the URL that was used to get the results. Right (context) click on it and open it in a new tab/window. You should get something like:

http://localhost:8983/solr/my_core_name/select?q=*%3A*&wt=json&indent=true

Now, I want to get it into a delete format. I replace the select?q= with update?commit=true&stream.body=<delete><query> and, at the end, the &wt=json&indent=true with </query></delete>.

So I end up with:

http://localhost:8983/solr/my_core_name/update?commit=true&stream.body=<delete><query>*%3A*</query></delete>

Take a deep breath, do whatever you do for good luck, and submit the url (enter key works).

Now, you should be able to go back to the Solr admin page and run the original query and get zero results.


For everyone who doesn't like a lot of words :-)

Solr Admin: remove data from Core


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

select XML on collection Document tab and update below parameter.

<delete><query>*:*</query></delete>