|
19 | 19 |
|
20 | 20 | import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
21 | 21 | import co.elastic.clients.elasticsearch._types.FieldValue;
|
22 |
| -import co.elastic.clients.elasticsearch._types.Script; |
23 |
| -import co.elastic.clients.elasticsearch._types.mapping.RuntimeField; |
24 |
| -import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType; |
25 | 22 | import co.elastic.clients.elasticsearch._types.mapping.TypeMapping;
|
26 | 23 | import co.elastic.clients.elasticsearch.cluster.HealthRequest;
|
27 | 24 | import co.elastic.clients.elasticsearch.cluster.HealthResponse;
|
|
30 | 27 | import co.elastic.clients.elasticsearch.core.SearchRequest;
|
31 | 28 | import co.elastic.clients.elasticsearch.core.search.ResponseBody;
|
32 | 29 | import co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient;
|
| 30 | +import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsRequest; |
| 31 | +import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsResponse; |
33 | 32 | import co.elastic.clients.elasticsearch.indices.IndexSettings;
|
34 | 33 | import co.elastic.clients.transport.ElasticsearchTransport;
|
35 | 34 | import co.elastic.clients.transport.TransportOptions;
|
@@ -85,30 +84,12 @@ public class DevTests {
|
85 | 84 | void someTest() throws IOException {
|
86 | 85 |
|
87 | 86 | ElasticsearchClient client = imperativeElasticsearchClient;
|
| 87 | + ElasticsearchIndicesClient indicesClient = client.indices(); |
88 | 88 |
|
89 |
| - String index = "testindex"; |
| 89 | + indicesClient.create(b -> b.index("testindex")); |
90 | 90 |
|
91 |
| - var p = new Product("p1", 42.0); |
92 |
| - |
93 |
| - client.index(ir -> ir // |
94 |
| - .index(index)// |
95 |
| - .document(p)); |
96 |
| - |
97 |
| - client.indices().flush(f -> f.index(index)); |
98 |
| - |
99 |
| - RuntimeField runtimeField = RuntimeField.of(rf -> rf // |
100 |
| - .type(RuntimeFieldType.Double) // |
101 |
| - .script(Script.of(s -> s // |
102 |
| - .inline(i -> i. // |
103 |
| - source("emit(doc['price'].value * 1.19)") // |
104 |
| - ) // |
105 |
| - )) // |
106 |
| - ); // |
107 |
| - |
108 |
| - client.search(sr -> sr // |
109 |
| - .index(index) // |
110 |
| - .runtimeMappings("priceWithTax", runtimeField), // |
111 |
| - Person.class); // |
| 91 | + GetIndicesSettingsResponse getIndicesSettingsResponse = indicesClient |
| 92 | + .getSettings(GetIndicesSettingsRequest.of(b -> b.index("testindex").includeDefaults(true))); |
112 | 93 | }
|
113 | 94 |
|
114 | 95 | static class ReactiveClient {
|
@@ -371,7 +352,7 @@ private ResponseBody<EntityAsMap> searchReactive(SearchRequest searchRequest) {
|
371 | 352 |
|
372 | 353 | private ClientConfiguration clientConfiguration() {
|
373 | 354 | return ClientConfiguration.builder() //
|
374 |
| - .connectedTo("thranduil.local.:9200")// |
| 355 | + .connectedTo("localhost:9200")// |
375 | 356 | .withBasicAuth("elastic", "hcraescitsale").withProxy("localhost:8080") //
|
376 | 357 | .withHeaders(() -> {
|
377 | 358 | HttpHeaders headers = new HttpHeaders();
|
|
0 commit comments