jamescarr/mongoosastic — pull request #120 by antoineverger (2014-09-26 07:33:05+00:00)
Title: Add the esTruncate static method to remove all documents from an index

Hi,

I created a method to remove all documents from an index. The reason why is that I use mongoosastic in one of my projects and in my integration tests, between two test cases, I manually drop all elements of mongodb collections. The problem is that the documents are not deleted from ES mainly because the synchronize method does not empty the index before putting the documents. This static is, according to me, the first step for properly synchronizing data between mongodb and ES. If you are ok with this PR, I will refactor a bit synchronize so that it first truncate the index and then synchronize the elements.

FYI, the new method has its own test file but I didn't include it to the readme.