This repository illustrates and demonstrates the use of ElasticSearch Java API with most up to date version of ElasticSearch which provides Java High Level REST Client. If you want to see the sample of the old version, please visit the oldVersion branch.
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);
}
QueryBuilders.wildcardQuery("_all", "*" + query.toLowerCase() + "*")
DeleteRequest deleteRequest = new DeleteRequest(props.getIndex().getName(), props.getIndex().getType(), id);
mvn spring-boot:run
docker run -d --name elasticsearch -p 8080:8080 hakdogan/elasticsearch:newVersion