Time for action – cleaning an index

One of the most common things you will need to do when you are starting with your own experiments is to clean the index, deleting all the documents in it. This is a very common case when you want a fresh start with the data, to be able to see more clearly what is happening, or just because you are writing a script for updating your index and you want to test it, in order to make its behavior repeatable:

  1. Clearing the index corresponds to deleting every document:
    >> curl -X POST 'http://localhost:8983/solr/simple/update?commit=true' -H 'Content-Type: text/xml' --data-binary '<delete><query>*:*</query></delete>'
    
  2. As you see, the request for deletion is made by using a specific XML syntax; in this case we write it all in-line for simplicity, but the XML data can be also saved to a file.

What just happened?

We can easily delete Solr documents by using a query for selecting them. The q=*:* parameter here tells Solr that we are searching in every field for every term occurrence, so we are obtaining all the documents, and once selected deleting them (Solr will identify them internally by their id field).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.180.43