# Using NEST to Enable/Disable Index Refresh

**URL:** <https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600>\
**Category:** Elasticsearch\
**Created:** [July 18, 2017, 2:20pm UTC](https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600 "2017-07-18T14:20:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![han1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han1/32/20141_2.png) [@han1](https://discuss.elastic.co/u/han1)\
**Post date:** [July 18, 2017, 2:20pm UTC](https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600/1 "2017-07-18T14:20:30Z")

</div>

What we are trying to do is to index a bunch of documents in batches i.e.

```
    foreach (var batch in props.ChunkBy(100))
    {    
    
        var result = await client.IndexManyAsync<Type>(batch, indexName);
                   
    }

```

We would like to **STOP** Elasticsearch **REFRESHING** the Index until we have finished indexing all the batches. Then enable and refresh the index.

How can we achieve this with the NEST library

Many thanks

---

<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:** [July 21, 2017, 8:24am UTC](https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600/2 "2017-07-21T08:24:02Z")

</div>

To disable the refresh interval

```
client.UpdateIndexSettings("index-name", u => u
    .IndexSettings(i => i
        .RefreshInterval("-1")
    )
);

```

To enable the refresh interval again and set it to 1 second

```
client.UpdateIndexSettings("index-name", u => u
    .IndexSettings(i => i
        .RefreshInterval("1s")
    )
);

```

Async variant of `UpdateIndexSettingsAsync()` can also be used

---

<div class="post-metadata">

**Author:** ![han1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han1/32/20141_2.png) [@han1](https://discuss.elastic.co/u/han1)\
**Post date:** [July 21, 2017, 10:14am UTC](https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600/3 "2017-07-21T10:14:10Z")

</div>

Thank you very much Russ,  
Any idea on my other question as to can one find out which field in the  
document matched the query.

Many thanks

---

<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:** [August 18, 2017, 10:22am UTC](https://discuss.elastic.co/t/using-nest-to-enable-disable-index-refresh/93600/4 "2017-08-18T10:22:49Z")

</div>

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