diff --git a/README.md b/README.md index 606d2c7..897483a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ I believe it could be beneficial for many, so I've made the code available here. You're welcome to contribute your own examples if you'd like. -This repository is tested against Elasticsearch 8.15.3. +This repository is tested against Elasticsearch 8.16.0. We automatically start a Docker image using the [Elasticsearch module for TestContainers](https://www.testcontainers.org/modules/elasticsearch/). diff --git a/pom.xml b/pom.xml index 465ed91..9cea8fe 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ - 8.15.3 + 8.16.0 2.18.1 2.24.1 2.0.16 diff --git a/src/test/java/fr/pilato/test/elasticsearch/hlclient/EsClientIT.java b/src/test/java/fr/pilato/test/elasticsearch/hlclient/EsClientIT.java index 973fa3f..1a9a0be 100644 --- a/src/test/java/fr/pilato/test/elasticsearch/hlclient/EsClientIT.java +++ b/src/test/java/fr/pilato/test/elasticsearch/hlclient/EsClientIT.java @@ -44,6 +44,7 @@ import co.elastic.clients.elasticsearch.transform.GetTransformResponse; import co.elastic.clients.elasticsearch.transform.PutTransformResponse; import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonpMappingException; import co.elastic.clients.json.jackson.JacksonJsonpMapper; import co.elastic.clients.transport.ElasticsearchTransport; import co.elastic.clients.transport.TransportException; @@ -431,7 +432,7 @@ void rangeQuery() throws IOException { client.indices().refresh(rr -> rr.index(indexName)); SearchResponse response = client.search(sr -> sr.index(indexName) .query(q -> q.range(rq -> rq - .number(nrq -> nrq.field("foo").from(0.0).to(1.0)) + .number(nrq -> nrq.field("foo").gte(0.0).lte(1.0)) )) , ObjectNode.class); assertNotNull(response.hits().total()); @@ -924,28 +925,39 @@ void esql() throws IOException, SQLException { // Using the Raw ES|QL API try (BinaryResponse response = client.esql().query(q -> q.query(query)); InputStream is = response.content()) { - // The response object is {"columns":[{"name":"country","type":"text"}],"values":[["france"]]} + // The response object is {"took":5,"columns":[{"name":"name","type":"text"}],"values":[["David"]]} ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(is); assertNotNull(node); - assertEquals(2, node.size()); + assertEquals(3, node.size()); assertEquals(1, node.get("columns").size()); assertEquals("name", node.get("columns").get(0).get("name").asText()); assertEquals(1, node.get("values").size()); assertEquals("David", node.get("values").get(0).get(0).asText()); + assertTrue(node.get("took").asInt() > 0); } // Using the JDBC ResultSet ES|QL API + // And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903 try (ResultSet resultSet = client.esql().query(ResultSetEsqlAdapter.INSTANCE, query)) { + fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code."); assertTrue(resultSet.next()); assertEquals("David", resultSet.getString(1)); + } catch (JsonpMappingException e) { + // This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903 } // Using the Object ES|QL API - Iterable persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query); - for (Person person : persons) { - assertNull(person.getId()); - assertNotNull(person.getName()); + // And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903 + try { + Iterable persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query); + fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code."); + for (Person person : persons) { + assertNull(person.getId()); + assertNotNull(person.getName()); + } + } catch (JsonpMappingException e) { + // This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903 } }