i am new to elk, I have an simple code of elasticsearch in Java like this :
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "elasticsearch")
.put("client.transport.sniff", true).build();
TransportClient client = TransportClient.builder().settings(settings).build();
client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("1.2.3.4", 9200)));
SearchResponse response = client.prepareSearch("logstash-log*").setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(fieldQuery("host", "2.3.4.5"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
SearchHit[] results = response.getHits().getHits();
for (SearchHit hit : results) {
System.out.println(hit.getId()); //prints out the id of the document
Map<String,Object> result = hit.getSource(); //the retrieved document
}
System.out.println("test");
So, can you give me suggestion, I've looking for the solution Thanks...