Subscribe

Close

Thank you for visiting!

Please consider subscribing to the RSS feed or following me on Twitter.

Delete Documents From Solr Index By Query

If you simply want to delete documents from your Solr index by using the web interface, here's a code snippet that lets you do so:

http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253</query></delete>&commit=true

This lets you delete documents where the id field matches 298253.

If you want to delete items that matches more than one field, just add another query:

http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253</query>
<query>entitytype:BlogEntry</query></delete>&commit=true

If you want to delete all items in the index, just use this query:

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

Comments

Exactly what I was looking for :) Thank you!!

After re-indexing my Solr index and running cron, I queried Solr directly to ensure the locative data was added to the documents. Solr Query Coordinates. I then used the new spatial query syntax.

Saved lot of time .Thanks

thanks

How can I delete all those documents which don't contain a particular field?

Thanks!

Thanks,

this is used for <a href='http://antguider.blogspot.com/2012/06/solr-search.html'>Solr Search</a>

Thanks , It worked well

can u pls tell me for update the id from 1 to 2

Warning:
In my test the url
http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253</query>
<query>entitytype:BlogEntry</query></delete>&commit=true

Deleted all of BlogEntry docs!

The url below works for me.
http://localhost:8983/solr/update?stream.body=
<delete><query>id:298253%20AND%20entitytype:BlogEntry</query></delete>&commit=true

Thanks.

Yeah Edinho - I got misled too and lost a lot of items! This article should be edited to include the AND!

Good info though. helped a lot.

I am trying to delete document from solr using multiple attributes but not Id.
My query is this :

http://10.250.240.35:8080/solr/update?stream.body=%3Cdelete%3E%3Cquery%3Ename:$name%20AND%20version:1.2%3C/query%3E%3C/delete%3E&commit=true

But when I execute this query, it doesnt delete the document from Solr but returns response.

Can you please tell me where I am wrong ?

To the top