I'm trying this basic elasticsearch example from there guide to use java client API in a spring boot project.
but it gives me the following error when running:
java.lang.NoSuchMethodError: org.apache.http.client.utils.URLEncodedUtils.formatSegments([Ljava/lang/String;)Ljava/lang/String;
here is my POM file.
the code:
public void retrieveAuditMessages() throws IOException {
// Create the low-level client
RestClient restClient = RestClient.builder(
new HttpHost("localhost", 9200)
).build();
// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(
restClient, new JacksonJsonpMapper()
);
// Create the API client
ElasticsearchClient client = new ElasticsearchClient(transport);
SearchResponse<String> search = client.search(s -> s
.index("logstash-wildfly*")
.query(q -> q
.term(t -> t
.field("host")
.value(v -> v.stringValue("aboSaadoosh"))
)
),
String.class);
for(Hit<String> hit: search.hits().hits())
{
System.out.println(hit.source());
}
}
I guess it's a problem with dependencies, but I don't know how to solve it.
I'm using Elasticsearch version 8.1.1 java client API and spring boot 1.5.7.RELEASE