Borort

The sky’s the limit…

Select/delete all items in Solr

with one comment

To select all items for a field in Solr you can use the query : some_item:[* TO *], but if this field is missing from some documents you will not select those documents.

To select all documents you can use the id defined in /conf/schema.xml, for example: <uniqueKey>solr_id</uniqueKey> you can use solr_id:[* TO *].

Now that you have all documents selected you can delete them :D

To delete all documents in Solr use this update xml:

<delete><query>solr_id:[*TO *]</query></delete>

and of course you have to commit:

<commit />

That’s all !

Source: http://blog.tremend.ro/2007/03/02/selectdelete-all-items-in-solr/

Written by borort

July 13, 2008 at 2:17 pm

Posted in Search Engines, Solr

One Response

Subscribe to comments with RSS.

  1. You can find all docs (with or without a uniqueKey field) using *:*

    Likewise you can delete all docs using that query as well … but if your index is particularly huge it can be more efficient in Solr 1.2 to just stop solr, rm -r the index directory and start solr again.

    in Solr 1.3, *:* will be be as efficient as rm’ing the directory yourself, but without needing to start/stop.

    Hoss

    July 14, 2008 at 1:29 am


Leave a Reply