bsadeh/scalastic — pull request #40 by martinb3 (2014-04-21 17:08:12+00:00)
Title: ActionRequestValidationException on deleteIndex() during beforeEach()

Hello --

I'm noticing the following in IndexCrud.scala:
```
trait DeleteIndex {
self: Indexer =>
def deleteIndex(indices: Iterable[String] = Nil, timeout: Option[String] = None) = deleteIndex_send(indices, timeout).actionGet
def deleteIndex_send(indices: Iterable[String] = Nil, timeout: Option[String] = None) = deleteIndex_prepare(indices, timeout).execute
def deleteIndex_prepare(indices: Iterable[String] = Nil, timeout: Option[String] = None) = {
val request = client.admin.indices.prepareDelete(indices.toArray: _*)
timeout foreach { request.setTimeout(_) }
request
}

/** caveat: if none of the indices exists, we will encounter a validation exception */
def deleteIndexIfExists(indices: Iterable[String] = Nil, timeout: Option[String] = None) = deleteIndexIfExists_send(indices, timeout).actionGet
def deleteIndexIfExists_send(indices: Iterable[String] = Nil, timeout: Option[String] = None) = deleteIndexIfExists_prepare(indices, timeout).execute
def deleteIndexIfExists_prepare(indices: Iterable[String] = Nil, timeout: Option[String] = None) = {
val existing = indices filter (exists(_).isExists)
val toDelete: Iterable[String] = if (existing.isEmpty) null else existing
deleteIndex_prepare(toDelete, timeout)
}
}
```
How are these tests ever passing if they throw an exception on delete() when I'm starting from scratch with no indexes? Are you doing some special prep step that I'm not catching?

Here's the exception:
```
org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: index / indices is missing;
```

Thank you,

Martin