|
4 | 4 |
|
5 | 5 | using Elastic.Clients.Elasticsearch.Analysis;
|
6 | 6 | using Elastic.Clients.Elasticsearch.IndexManagement;
|
| 7 | +using Elastic.Clients.Elasticsearch.Mapping; |
7 | 8 | using Elastic.Clients.Elasticsearch.QueryDsl;
|
8 | 9 | using System.Collections.Generic;
|
9 | 10 | using System.Threading.Tasks;
|
@@ -83,4 +84,45 @@ public async Task CreateIndexWithAnalysisSettings_SerializesCorrectly()
|
83 | 84 | var objectJson = await SerializeAndGetJsonStringAsync(createRequest);
|
84 | 85 | objectJson.Should().Be(json);
|
85 | 86 | }
|
| 87 | + |
| 88 | + [U] |
| 89 | + public async Task CreateIndexWithDynamicTemplates_SerializesCorrectly() |
| 90 | + { |
| 91 | + var myTemplate = new DynamicTemplate |
| 92 | + { |
| 93 | + PathMatch = "testPathMatch", |
| 94 | + Mapping = new KeywordProperty() |
| 95 | + }; |
| 96 | + |
| 97 | + var descriptor = new CreateIndexRequestDescriptor("test") |
| 98 | + .Mappings(m => m |
| 99 | + .DynamicTemplates(new[] |
| 100 | + { |
| 101 | + new Dictionary<string, DynamicTemplate> |
| 102 | + { |
| 103 | + { "testTemplateName", myTemplate } |
| 104 | + } |
| 105 | + })); |
| 106 | + |
| 107 | + var json = await SerializeAndGetJsonStringAsync(descriptor); |
| 108 | + |
| 109 | + await Verifier.VerifyJson(json); |
| 110 | + |
| 111 | + var createRequest = new CreateIndexRequest("test") |
| 112 | + { |
| 113 | + Mappings = new TypeMapping |
| 114 | + { |
| 115 | + DynamicTemplates = new[] |
| 116 | + { |
| 117 | + new Dictionary<string, DynamicTemplate> |
| 118 | + { |
| 119 | + { "testTemplateName", myTemplate } |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | + }; |
| 124 | + |
| 125 | + var objectJson = await SerializeAndGetJsonStringAsync(createRequest); |
| 126 | + objectJson.Should().Be(json); |
| 127 | + } |
86 | 128 | }
|
0 commit comments