java api _search
public void doAggr() {
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("192.168.0.106", 9200, "http"),
new HttpHost("192.168.0.106", 9201, "http")));
// 갯수 count
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.termQuery("data", "120"));
sourceBuilder.from(0);
sourceBuilder.size(5);
sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("today190108");
searchRequest.source(sourceBuilder);
try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
System.out.println(searchResponse);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
'ELK > elasticsearch' 카테고리의 다른 글
java api2 (0) | 2019.01.25 |
---|---|
java api (0) | 2019.01.25 |
java elasticsearch api 인덱스 생성 (0) | 2019.01.24 |
Java _ elasticsearch (0) | 2019.01.15 |
임시 - 주말간 정리 (0) | 2019.01.08 |