Close index API does not seem to provide option to ignore missing indexes

I've recently tried to use the close functionality described in:

https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-open-close.html

Yet it seems that the option ignore_unavailable is not working for closing an index. I've tried:

POST /<indexname>/_close?ignore_unavailable=true

as well as (with various combinations of double quotes too)

POST /<indexname>/_close
{
    ignore_unavailable: true
}

What I'm getting in both cases is the following:

{
   "error": "RemoteTransportException[[Patsy Walker][inet[/<XXXXXXXX>:9300]][indices:admin/close]]; nested: IndexMissingException[[foo] missing]; ",
   "status": 404
}

where =foo in my case. I'm not expecting this exception to be thrown. The operation should silently complete.

I'm using version 1.7.2 of elasticsearch.
I'm wondering if this is a genuine bug or if the documentation is not up-to-date.
If someone else could check this on their installation that would be appreciated.
All you need to do is execute these queries for an index you know does not exist.

I take it you're using sense?

POST /indexname/_close?ignore_unavailable=true worked fine for me. The 404 seems to indicate that the index you are trying to close doesn't exists though, can you check via _cat/indices?

Thanks for trying the test

I know that the index does not exist. This post if all about the behaviour I would expect in the case that the index does not exist.

The point is that I would not expect the exception to be thrown when ignore_unavailable=true but I would expect it to be thrown when ignore_unavailable=false.

What do you mean by 'worked fine' when you did your test? If you got a 404 then I would say it did not work fine.

That's about unavailable shards, not unavailable indices though.

Ah, ok, that explains why it's not working as I expect. This means the documentation is misleading since it says the following:

"An error will be thrown if the request explicitly refers to a missing index. This behaviour can be disabled using the ignore_unavailable=true parameter"

https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-open-close.html

Hmm ok, that may be a misunderstanding on my part. That setting is also used in snapshot for shards.

I'll ask around.

Hi Mark, Thanks for looking into this.

I've noticed that when using the restore command that ignore_unavailable=true behaves as I expect. This means that I can restore a snapshot even if all my indexes are missing and it will not throw an exception. This is why I was expecting similar behaviour for close command with the same option setting.

Checkout https://github.com/elastic/elasticsearch/issues/14102