Skip to content

Commit 5d80d8d

Browse files
committed
[Docs] Update Indices Exists section
1 parent d94825c commit 5d80d8d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/contents/nest/indices/indices-exists.markdown

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ menuitem: indices-exists
1010

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

13-
## Unknown index
13+
## Examples
1414

15-
var r = this.ConnectedClient.IndexExists("yadadadadadaadada");
16-
Assert.False(r.Exists);
17-
//404 is a valid response in this case
18-
Assert.True(r.IsValid);
15+
### Fluent Syntax
1916

20-
## Known index
17+
var result = client.IndexExists(i => i.Index("myindex"));
2118

22-
var r = this.ConnectedClient.IndexExists("nest_test_data");
23-
Assert.True(r.Exists);
19+
### Object Initializer Syntax
2420

21+
var request = new IndexExistsRequest("myindex");
22+
var result = client.IndexExists(request);
2523

24+
## Handling the Index Exists response
25+
26+
`result` in the above examples is an `IExistsResponse` which contains a bool property `Exists`.
27+
28+
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`.

0 commit comments

Comments
 (0)