Answer the question
In order to leave comments, you need to log in
What Java code library is used for Elasticsearch?
I decided to try to leave requests in elastic in Java, and I just can’t figure out which client to take and how to live with this stuff ..
There are three of the official clients.
There is a transport client in Java (which is on port 9300) - it seems to be deprecated, and it has its own for each version ...
There is a low-level REST client.
There is a high-level REST client that works through a low-level ...
Maybe someone will tell you something like Python's elasticsearch-dsl?
And I would like to know who uses what.
Answer the question
In order to leave comments, you need to log in
I will answer myself.
I will add, there is also a jest client - https://www.elastic.co/blog/found-java-clients-for...
But you need to drag the official transport client to it, mainly because of QueryBuilders, which is generally not bad ( I was starting to write classes for query-mapping myself)
----
In general, we tear everything out of jackson something like this
String query = "{\n" +
" \"query\": { \"match_all\": {}\n" +
" }" +
"}\n" +
"\n" +
"";
Response response = client.performRequest("GET","/offers_v1/offer/_search", new Hashtable<>(),
new StringEntity(query));
HttpEntity entity = response.getEntity();
ObjectMapper ob = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ResponseHits responseHits = ob.readValue(entity.getContent(), ResponseHits.class);
List<Hit> hits = responseHits.getHits().getHits();
return Results.html("index").put("hits", hits);
public class ResponseHits {
private Hits hits;
}
public class Hits {
private List<Hit> hits;
}
public class Hit {
@JsonProperty(value = "_index")
private String index;
@JsonProperty(value = "_type")
private String type;
@JsonProperty(value = "_id")
private String id;
@JsonProperty(value = "_score")
private Double score;
@JsonProperty(value = "_source")
private Hashtable<String, Object> source;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question