|
31 | 31 | import co.elastic.clients.elasticsearch.cat.ThreadPoolResponse; |
32 | 32 | import co.elastic.clients.elasticsearch.cluster.PutComponentTemplateResponse; |
33 | 33 | import co.elastic.clients.elasticsearch.core.*; |
| 34 | +import co.elastic.clients.elasticsearch.core.search.HighlightField; |
34 | 35 | import co.elastic.clients.elasticsearch.ilm.PutLifecycleResponse; |
35 | 36 | import co.elastic.clients.elasticsearch.indices.*; |
36 | 37 | import co.elastic.clients.elasticsearch.ingest.PutPipelineResponse; |
|
43 | 44 | import co.elastic.clients.transport.endpoints.BinaryResponse; |
44 | 45 | import co.elastic.clients.util.BinaryData; |
45 | 46 | import co.elastic.clients.util.ContentType; |
| 47 | +import co.elastic.clients.util.NamedValue; |
46 | 48 | import com.fasterxml.jackson.core.type.TypeReference; |
47 | 49 | import com.fasterxml.jackson.databind.JsonNode; |
48 | 50 | import com.fasterxml.jackson.databind.ObjectMapper; |
@@ -328,7 +330,8 @@ void highlight() throws IOException { |
328 | 330 | final SearchResponse<Void> response = client.search(sr -> sr |
329 | 331 | .index(indexName) |
330 | 332 | .query(q -> q.match(mq -> mq.field("foo").query("bar"))) |
331 | | - .highlight(h -> h.fields("foo", hf -> hf.maxAnalyzedOffset(10))) |
| 333 | + .highlight(h -> h |
| 334 | + .fields(NamedValue.of("foo", HighlightField.of(hf -> hf.maxAnalyzedOffset(10))))) |
332 | 335 | , Void.class); |
333 | 336 | assertThat(response.hits().total()).isNotNull(); |
334 | 337 | assertThat(response.hits().total().value()).isEqualTo(1); |
@@ -969,22 +972,16 @@ void esql() throws IOException, SQLException { |
969 | 972 | { |
970 | 973 | // Using the Raw ES|QL API |
971 | 974 | try (final BinaryResponse response = client.esql().query(q -> q.query(query)); InputStream is = response.content()) { |
972 | | - // The response object is { |
973 | | - // "took" : 4, |
974 | | - // "is_partial" : false, |
975 | | - // "columns" : [ { |
976 | | - // "name" : "name", |
977 | | - // "type" : "text" |
978 | | - // } ], |
979 | | - // "values" : [ [ "David" ] ] |
980 | | - //} |
| 975 | + // The response object is {"took":173,"is_partial":false,"documents_found":1,"values_loaded":1,"columns":[{"name":"name","type":"text"}],"values":[["David"]]} |
981 | 976 | final ObjectMapper mapper = new ObjectMapper(); |
982 | 977 | final JsonNode jsonNode = mapper.readTree(is); |
983 | | - assertThat(jsonNode).isNotNull().hasSize(4); |
| 978 | + assertThat(jsonNode).isNotNull().hasSize(6); |
984 | 979 | assertThat(jsonNode.get("columns")).isNotNull().hasSize(1).first().satisfies(column -> assertThat(column.get("name").asText()).isEqualTo("name")); |
985 | 980 | assertThat(jsonNode.get("values")).isNotNull().hasSize(1).first().satisfies(value -> assertThat(value).hasSize(1).first().satisfies(singleValue -> assertThat(singleValue.asText()).isEqualTo("David"))); |
986 | 981 | assertThat(jsonNode.get("took").asInt()).isGreaterThan(0); |
987 | 982 | assertThat(jsonNode.get("is_partial").asBoolean()).isFalse(); |
| 983 | + assertThat(jsonNode.get("documents_found").asLong()).isEqualTo(1); |
| 984 | + assertThat(jsonNode.get("values_loaded").asLong()).isEqualTo(1); |
988 | 985 | } |
989 | 986 | } |
990 | 987 |
|
|
0 commit comments