Original link: https://github.com/hakdogan/ElasticSearch
Make a separate service using spring-boot of Java, CRUD for data in ElasticSearch.
The client added in version 6.0.0-beta1 and it works on top of the Java low level rest client.
RetHighLevelClient(RestClient.builder(new HttpHost(props.getRestClient().getHostname(),
props.getRestClient().getPort(), props.getRestClient().getScheme())));
IndexRequest request = new IndexRequest(props.getIndex().getName(), props.getIndex().getType());
request.source(gson.toJson(document), XContentType.JSON);
IndexResponse response = client.index(request);
sourceBuilder.query(builder);
SearchRequest searchRequest = getSearchRequest();
SearchResponse searchResponse = client.search(searchRequest);
SearchHits hits = searchResponse.getHits();
SearchHit[] searchHits = hits.getHits();
for (SearchHit hit : searchHits) {
Document doc = gson.fromJson(hit.getSourceAsString(), Document.class);
doc.setId(hit.getId());
result.add(doc);
}
DeleteRequest deleteRequest = new DeleteRequest(props.getIndex().getName(), props.getIndex().getType(), id);
mvn spring-boot:run