use of org.elasticsearch.client.Request in project yyl_example by Relucent.
the class ElasticsearchTest method existsIndices.
// 查询索引是否存在
private static boolean existsIndices(RestClient client) throws Exception {
Request request = new Request("HEAD", INDEX);
Response response = client.performRequest(request);
boolean exists = response.getStatusLine().getReasonPhrase().equals("OK");
System.out.println(exists);
return exists;
}
use of org.elasticsearch.client.Request in project yyl_example by Relucent.
the class ElasticsearchTest method info.
// 验证ES集群是否搭建成功
private static void info(RestClient client) throws Exception {
// curl -X GET "http://localhost:9200/_count?pretty"
Request request = new Request("GET", "");
request.addParameter("pretty", "true");
Response response = client.performRequest(request);
System.out.println(EntityUtils.toString(response.getEntity()));
}
use of org.elasticsearch.client.Request in project yyl_example by Relucent.
the class ElasticsearchTest method createIndex.
// 创建索引
private static void createIndex(RestClient client) throws Exception {
Request request = new Request("PUT", INDEX);
Response response = client.performRequest(request);
System.out.println(EntityUtils.toString(response.getEntity()));
}
use of org.elasticsearch.client.Request in project yyl_example by Relucent.
the class ElasticsearchTest method createDocumentPost.
// 创建文档
// POST方法:在这个类型下存储文档
private static void createDocumentPost(RestClient client) throws Exception {
Request request = new Request("POST", INDEX + "/" + TYPE);
request.setEntity(new NStringEntity(//
"{" + //
"\"name\":\"welcome\"," + //
"\"value\":\"universe\"" + "}", ContentType.APPLICATION_JSON));
Response response = client.performRequest(request);
System.out.println(EntityUtils.toString(response.getEntity()));
}
use of org.elasticsearch.client.Request in project immutables by immutables.
the class ElasticsearchOps method nextScroll.
/**
* Fetches next results given a scrollId.
*/
Single<Json.Result> nextScroll(String scrollId) {
// fetch next scroll
final Request request = new Request("POST", "/_search/scroll");
final ObjectNode payload = mapper.createObjectNode().put("scroll", "1m").put("scroll_id", scrollId);
request.setJsonEntity(payload.toString());
return transport.execute(request).map(r -> responseConverter().apply(r));
}
Aggregations