# Regex for \_close indices

**URL:** <https://discuss.elastic.co/t/regex-for-close-indices/128929>\
**Category:** Elasticsearch\
**Created:** [April 20, 2018, 7:31pm UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929 "2018-04-20T19:31:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [April 20, 2018, 7:31pm UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/1 "2018-04-20T19:31:26Z")

</div>

Hi,  
I have few indices that are named like

cloudtrail-dev-abc-2017  
cloudtrail-dev-abc-2018  
cloudtrail-dev-def-2017  
cloudtrail-dev-def-2018

If i need to close all indices that ends with 2017. Is there a way i can do this with regex.

--  
Niraj

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 20, 2018, 7:47pm UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/2 "2018-04-20T19:47:22Z")

</div>

May be

```
POST *2017/_close

```

?

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [April 20, 2018, 11:14pm UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/3 "2018-04-20T23:14:05Z")

</div>

@dadoonet It didn't work.

```
{
"error": {
    "root_cause": [
        {
            "type": "index_not_found_exception",
            "reason": "no such index",
            "index_uuid": "_na_",
            "resource.type": "index_or_alias",
            "resource.id": "*2018",
            "index": "*2018"
        }
    ],
    "type": "index_not_found_exception",
    "reason": "no such index",
    "index_uuid": "_na_",
    "resource.type": "index_or_alias",
    "resource.id": "*2018",
    "index": "*2018"
},
"status": 404

```

}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 21, 2018, 4:48am UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/4 "2018-04-21T04:48:38Z")

</div>

May be

```
POST *2017/_close?expand_wildcards=open
```

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [April 21, 2018, 8:12am UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/5 "2018-04-21T08:12:02Z")

</div>

> [@dadoonet](#):
>
> ?expand\_wildcards=open

It works. Thanks a lot

---

<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:** [May 19, 2018, 8:12am UTC](https://discuss.elastic.co/t/regex-for-close-indices/128929/6 "2018-05-19T08:12:17Z")

</div>

Closed on May 19, 2018, 8:12am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
