|
26 | 26 |
|
27 | 27 | import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
28 | 28 | import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
|
29 |
| -import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; |
30 | 29 | import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
31 | 30 | import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
|
32 | 31 | import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
|
33 | 32 | import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
|
34 | 33 | import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
|
35 | 34 | import org.elasticsearch.client.GetAliasesResponse;
|
| 35 | +import org.elasticsearch.client.indices.CreateIndexRequest; |
36 | 36 | import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
37 | 37 | import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
38 | 38 | import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
@@ -101,23 +101,36 @@ public DefaultReactiveIndexOperations(ReactiveElasticsearchOperations operations
|
101 | 101 | @Override
|
102 | 102 | public Mono<Boolean> create() {
|
103 | 103 |
|
104 |
| - String indexName = getIndexCoordinates().getIndexName(); |
| 104 | + IndexCoordinates index = getIndexCoordinates(); |
105 | 105 |
|
106 | 106 | if (boundClass != null) {
|
107 |
| - return createSettings(boundClass).flatMap(settings -> doCreate(indexName, settings)); |
| 107 | + return createSettings(boundClass).flatMap(settings -> doCreate(index, settings, null)); |
108 | 108 | } else {
|
109 |
| - return doCreate(indexName, null); |
| 109 | + return doCreate(index, null, null); |
110 | 110 | }
|
111 | 111 | }
|
112 | 112 |
|
| 113 | + @Override |
| 114 | + public Mono<Boolean> createWithMapping() { |
| 115 | + return createSettings() // |
| 116 | + .flatMap(settings -> // |
| 117 | + createMapping().flatMap(mapping -> // |
| 118 | + doCreate(getIndexCoordinates(), settings, mapping))); // |
| 119 | + } |
| 120 | + |
113 | 121 | @Override
|
114 | 122 | public Mono<Boolean> create(Document settings) {
|
115 |
| - return doCreate(getIndexCoordinates().getIndexName(), settings); |
| 123 | + return doCreate(getIndexCoordinates(), settings, null); |
116 | 124 | }
|
117 | 125 |
|
118 |
| - private Mono<Boolean> doCreate(String indexName, @Nullable Document settings) { |
| 126 | + @Override |
| 127 | + public Mono<Boolean> create(Document settings, Document mapping) { |
| 128 | + throw new UnsupportedOperationException("not implemented"); |
| 129 | + } |
119 | 130 |
|
120 |
| - CreateIndexRequest request = requestFactory.createIndexRequestReactive(indexName, settings); |
| 131 | + private Mono<Boolean> doCreate(IndexCoordinates index, @Nullable Document settings, @Nullable Document mapping) { |
| 132 | + |
| 133 | + CreateIndexRequest request = requestFactory.createIndexRequest(index, settings, mapping); |
121 | 134 | return Mono.from(operations.executeWithIndicesClient(client -> client.createIndex(request)));
|
122 | 135 | }
|
123 | 136 |
|
@@ -309,9 +322,9 @@ public IndexCoordinates getIndexCoordinates() {
|
309 | 322 | @Override
|
310 | 323 | public Flux<IndexInformation> getInformation(IndexCoordinates index) {
|
311 | 324 |
|
312 |
| - Assert.notNull(index, "index must not be null"); |
| 325 | + Assert.notNull(index, "index must not be null"); |
313 | 326 |
|
314 |
| - org.elasticsearch.client.indices.GetIndexRequest getIndexRequest = requestFactory.getIndexRequest(index); |
| 327 | + org.elasticsearch.client.indices.GetIndexRequest getIndexRequest = requestFactory.getIndexRequest(index); |
315 | 328 | return Mono
|
316 | 329 | .from(operations.executeWithIndicesClient(
|
317 | 330 | client -> client.getIndex(getIndexRequest).map(ResponseConverter::getIndexInformations)))
|
|
0 commit comments