question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

7.16.2 client esClient.shutdown(); not working

See original GitHub issue
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:open
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nicoloboschicommented, Apr 1, 2022

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.

1reaction
spinscalecommented, Jan 13, 2022

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 the terms query or the bool 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.html

Also, 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found