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

**URL:** <https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998>\
**Category:** Elasticsearch\
**Created:** [October 12, 2015, 9:53am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998 "2015-10-12T09:53:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![benfranklin79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benfranklin79/32/3620_2.png) [@benfranklin79](https://discuss.elastic.co/u/benfranklin79)\
**Post date:** [October 12, 2015, 9:53am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/1 "2015-10-12T09:53:07Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 12, 2015, 9:00pm UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/2 "2015-10-12T21:00:22Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![benfranklin79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benfranklin79/32/3620_2.png) [@benfranklin79](https://discuss.elastic.co/u/benfranklin79)\
**Post date:** [October 13, 2015, 8:27am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/3 "2015-10-13T08:27:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 13, 2015, 8:33am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/4 "2015-10-13T08:33:56Z")

</div>

> [@benfranklin79](#):
>
> ignore\_unavailable

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

---

<div class="post-metadata">

**Author:** ![benfranklin79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benfranklin79/32/3620_2.png) [@benfranklin79](https://discuss.elastic.co/u/benfranklin79)\
**Post date:** [October 13, 2015, 11:43am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/5 "2015-10-13T11:43:19Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/indices-open-close.html)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 13, 2015, 9:23pm UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/6 "2015-10-13T21:23:54Z")

</div>

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

I'll ask around.

---

<div class="post-metadata">

**Author:** ![benfranklin79](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benfranklin79/32/3620_2.png) [@benfranklin79](https://discuss.elastic.co/u/benfranklin79)\
**Post date:** [October 14, 2015, 8:44am UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/7 "2015-10-14T08:44:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 14, 2015, 8:32pm UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/8 "2015-10-14T20:32:10Z")

</div>

Checkout [https://github.com/elastic/elasticsearch/issues/14102](https://github.com/elastic/elasticsearch/issues/14102)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:44pm UTC](https://discuss.elastic.co/t/close-index-api-does-not-seem-to-provide-option-to-ignore-missing-indexes/31998/9 "2017-07-05T23:44:48Z")

</div>


