7.16.2 client esClient.shutdown(); not working
See original GitHub issue- using docs: https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html I get compile error
- ES server 7.14.2
- java 8:
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import java.io.IOException;
import org.apache.http.HttpHost;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RestClient;
.....
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchClient esClient = new ElasticsearchClient(transport);
SearchResponse<Account> search = esClient.search(s
-> s.index("account*")
.query(q -> q.term(t -> t.field("username").value(v -> v.stringValue("tmajer3")))),
Account.class);
for (Hit<Account> hit : search.hits().hits()) {
System.out.println(hit.source());
}
esClient.shutdown();
- error:
never complite
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
[es/snapshot.create] Missing [X-Elastic-Product] header #74
When performing a snapshot using the new Java client, it fails due to missing X-Elastic-Product header sent by Elasticsearch. Steps to reproduce ...
Read more >Connecting | Elasticsearch JavaScript Client [8.5] | Elastic
When connecting to Elastic Cloud, the client will automatically enable both request ... Running Elasticsearch without security enabled is not recommended.
Read more >Embedded elasticsearch test in java application - Stack Overflow
What's surprising is that I am pulling in ES client 7.16.2 and the class which is not found is present in org.elasticsearch:elasticsearch-x- ...
Read more >API Documentation — Elasticsearch 7.16.2 documentation
Elasticsearch low-level client. Provides a straightforward mapping from Python to ES REST endpoints. The instance has attributes cat , cluster , indices , ......
Read more >ElasticCC platform - Part 2 - Using the new Elasticsearch Java ...
The existing High Level Rest Client (HLRC) has been around for a few years ... even though this is not much of a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hit this issue today and I think that there’s something to do better. It’s a very weird Java API. For example, the ElasticsearchClient could implement Closeable interface and call the close on the outstanding restClient instance.
Please take your time to write up an easy to understand issue, in full sentences, including expectations (especially what you would expect), code samples that can be compiled locally (including imports and maybe even a proper test case sometimes).
Also, please do not mix up several issues, this makes it super hard to discuss, as github issues does not support threading.
The RestHighLevelClient is not part of this repo - this client however lead to the deprecation. What is your concrete question behind this? It is deprecated, this client is the successor.
The naming convention is correct, as this is how Elasticsearch is spelled.
Your last comment is without any context, please add some.
The
term
query only allows to search for a single term, take a look at theterms
query or thebool
query how to write several queries. Take a look at the different types of queries in the official Elasticsearch of the query DSL at https://www.elastic.co/guide/en/elasticsearch/reference/7.16/query-dsl.htmlAlso, the github issue tracker is for bugs, if you have questions about using the client, don’t hesitate to ask those in the discuss forum. Thanks a lot!