IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Indices exists

edit

Used to check if the index (indices) exists or not.

Examples

edit

Fluent Syntax

edit
    var result = client.IndexExists(i => i.Index("myindex"));

Object Initializer Syntax

edit
    var request = new IndexExistsRequest("myindex");
    var result = client.IndexExists(request);

Handling the Index Exists response

edit

result in the above examples is an IExistsResponse which contains a bool property Exists.

One thing to note is that if an index does not exist, Elasticsearch will return a 404. In this case, a 404 is a valid response and thus result.IsValid will be true.