|
44 | 44 | import co.elastic.clients.elasticsearch.transform.GetTransformResponse; |
45 | 45 | import co.elastic.clients.elasticsearch.transform.PutTransformResponse; |
46 | 46 | import co.elastic.clients.json.JsonData; |
| 47 | +import co.elastic.clients.json.JsonpMappingException; |
47 | 48 | import co.elastic.clients.json.jackson.JacksonJsonpMapper; |
48 | 49 | import co.elastic.clients.transport.ElasticsearchTransport; |
49 | 50 | import co.elastic.clients.transport.TransportException; |
@@ -431,7 +432,7 @@ void rangeQuery() throws IOException { |
431 | 432 | client.indices().refresh(rr -> rr.index(indexName)); |
432 | 433 | SearchResponse<ObjectNode> response = client.search(sr -> sr.index(indexName) |
433 | 434 | .query(q -> q.range(rq -> rq |
434 | | - .number(nrq -> nrq.field("foo").from(0.0).to(1.0)) |
| 435 | + .number(nrq -> nrq.field("foo").gte(0.0).lte(1.0)) |
435 | 436 | )) |
436 | 437 | , ObjectNode.class); |
437 | 438 | assertNotNull(response.hits().total()); |
@@ -924,28 +925,39 @@ void esql() throws IOException, SQLException { |
924 | 925 |
|
925 | 926 | // Using the Raw ES|QL API |
926 | 927 | try (BinaryResponse response = client.esql().query(q -> q.query(query)); InputStream is = response.content()) { |
927 | | - // The response object is {"columns":[{"name":"country","type":"text"}],"values":[["france"]]} |
| 928 | + // The response object is {"took":5,"columns":[{"name":"name","type":"text"}],"values":[["David"]]} |
928 | 929 | ObjectMapper mapper = new ObjectMapper(); |
929 | 930 | JsonNode node = mapper.readTree(is); |
930 | 931 | assertNotNull(node); |
931 | | - assertEquals(2, node.size()); |
| 932 | + assertEquals(3, node.size()); |
932 | 933 | assertEquals(1, node.get("columns").size()); |
933 | 934 | assertEquals("name", node.get("columns").get(0).get("name").asText()); |
934 | 935 | assertEquals(1, node.get("values").size()); |
935 | 936 | assertEquals("David", node.get("values").get(0).get(0).asText()); |
| 937 | + assertTrue(node.get("took").asInt() > 0); |
936 | 938 | } |
937 | 939 |
|
938 | 940 | // Using the JDBC ResultSet ES|QL API |
| 941 | + // And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903 |
939 | 942 | try (ResultSet resultSet = client.esql().query(ResultSetEsqlAdapter.INSTANCE, query)) { |
| 943 | + fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code."); |
940 | 944 | assertTrue(resultSet.next()); |
941 | 945 | assertEquals("David", resultSet.getString(1)); |
| 946 | + } catch (JsonpMappingException e) { |
| 947 | + // This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903 |
942 | 948 | } |
943 | 949 |
|
944 | 950 | // Using the Object ES|QL API |
945 | | - Iterable<Person> persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query); |
946 | | - for (Person person : persons) { |
947 | | - assertNull(person.getId()); |
948 | | - assertNotNull(person.getName()); |
| 951 | + // And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903 |
| 952 | + try { |
| 953 | + Iterable<Person> persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query); |
| 954 | + fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code."); |
| 955 | + for (Person person : persons) { |
| 956 | + assertNull(person.getId()); |
| 957 | + assertNotNull(person.getName()); |
| 958 | + } |
| 959 | + } catch (JsonpMappingException e) { |
| 960 | + // This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903 |
949 | 961 | } |
950 | 962 | } |
951 | 963 |
|
|
0 commit comments