# IndexExistsAsync in NEST 6.0

**URL:** <https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447>\
**Category:** Elasticsearch\
**Created:** [April 25, 2018, 9:54am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447 "2018-04-25T09:54:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![arpansahoo](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@arpansahoo](https://discuss.elastic.co/u/arpansahoo)\
**Post date:** [April 25, 2018, 9:54am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/1 "2018-04-25T09:54:58Z")

</div>

Hi,  
I am new to Elastic search, and was trying to check an Index before creating a new one.  
I am able to check it through IndexExists method but not by IndexExistsAsync. I have followed some of articles here in Elastic forum, but still unable to implement IndexExistsAsync method.

Please Help.

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [April 25, 2018, 10:15am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/2 "2018-04-25T10:15:04Z")

</div>

You want to check the list of indices before creating a newly named index to ensure no collision?

You will need to utilised the \_cat api such as here: [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/cat-indices.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/cat-indices.html)

---

<div class="post-metadata">

**Author:** ![arpansahoo](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@arpansahoo](https://discuss.elastic.co/u/arpansahoo)\
**Post date:** [April 25, 2018, 10:26am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/3 "2018-04-25T10:26:27Z")

</div>

Yes, this is a way.. but I want to check the index via code, using NEST.  
In NEST there are 2 methods,

1. IndexExists - I am able to get result using this
2. IndexExistsAsync - It's not working. I guess I am wrong in implementing it

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [April 25, 2018, 10:27am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/4 "2018-04-25T10:27:56Z")

</div>

for sure, can you share the code you are using ?

---

<div class="post-metadata">

**Author:** ![arpansahoo](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@arpansahoo](https://discuss.elastic.co/u/arpansahoo)\
**Post date:** [April 25, 2018, 10:34am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/5 "2018-04-25T10:34:31Z")

</div>

`public async Task ElasticIndexCheck(string indexName, ElasticClient client)  
{  
var req = new IndexExistsRequest(indexName);  
IExistsResponse response = await client.IndexExistsAsync(req);

```
        return response;            
    }`
```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [May 1, 2018, 1:00pm UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/6 "2018-05-01T13:00:51Z")

</div>

It's

```auto
var client = new ElasticClient();
var existsResponse = await client.IndexExistsAsync("index_name");

if (existsResponse.Exists)
{
    Console.WriteLine("It exists");
}

```

---

<div class="post-metadata">

**Author:** ![arpansahoo](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@arpansahoo](https://discuss.elastic.co/u/arpansahoo)\
**Post date:** [May 7, 2018, 6:50am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/7 "2018-05-07T06:50:20Z")

</div>

Sorry for my late response. But yes, it worked,, 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:** [June 4, 2018, 6:50am UTC](https://discuss.elastic.co/t/indexexistsasync-in-nest-6-0/129447/8 "2018-06-04T06:50:29Z")

</div>

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