Looking for software experts?
Need an expert advice on software development? Need consulting work done in time and at high standards? Tremend has the right solution for you.

We can provide expertise in:
  •    » high traffic and complex content website infrastructures using Java, PHP or .NET. More here ...
  •    » mobile applications for iPhone, Android or J2ME. More here ...

For an enquiry, send an email to contact [at] tremend [dot] ro.

Select/delete all items in Solr

March 2nd, 2007 by Sebastian Mitroi in General

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 !



DZoneGoogle ReaderYahoo MessengerRedditEmailDelicious

Related posts

  • Problem when adding elements to a TreeSet<Comparator> – some elements are not added
    I thought of sharing with you this little problem that I encountered when using a TreeSet to display an ordered list of items: I have some items stored in the database, each of them having a unique...
  • Create a Solr filter that replaces diacritics
    Some languages (like Romanian) have special characters (diacritics, often called accent marks). It's generally useful to remove diacritic marks from characters, for example when you create an index with...
  • DWR, JSON and IE6: beware keywords
    Spent quite a bit of time investigating an "IE bug". What happened: a particular AJAX request would work fine in Firefox but nothing would happen in IE6. Obvious steps were to monitor request and response...
  • Spring magic – Nested transactions
    The problem: Import a large number of items into a database, commiting valid ones and keeping track of invalid ones. All in a single transaction. Traditional solution: Tedious to write. Programatically...
  • Windows cannot find “url”
    If you've encountered this message: "Windows cannot find url" when clicking links in external applications (like for example Yahoo Messenger, Adobe Acrobat, etc), here's the solution as stated here: 1....
.

2 Responses

  1. Eric Passmore Says:

    The acts as solr schema is a little different. I found my self using

    <delete><query>id:[* TO *]</query></delete>
    <commit/>

    instead

  2. Henrik N Says:

    To get all results using acts_as_solr’s find_by_solr (not deleting, just searching), I found “type:[* TO *]” worked fine across all models, though “id:[* TO *]” didn’t. Thanks!

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.