Using NEST to Enable/Disable Index Refresh


#1

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


(Russ Cam) #2

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


#3

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


(system) #4

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