获取index的mapping
GetMappingsRequest request =new GetMappingsRequest();
request.indices(indexName);
GetMappingsResponse response =restHighLevelClient.indices().getMapping(request, RequestOptions.DEFAULT);
判断是否存在
GetIndexRequest request =new GetIndexRequest(index);
GetIndexResponse response =restHighLevelClient.indices().get(request, RequestOptions.DEFAULT);
更新某个字段
XContentBuilder jsonStr= XContentFactory.jsonBuilder().startObject()
.field("字段名", 字段值)
.endObject();
UpdateRequest updateRequest =new UpdateRequest(index, type, id).doc(jsonStr);
UpdateResponse updateResponse =restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
删除索引
DeleteRequest deleteRequest =new DeleteRequest(index, type, id);
DeleteResponse deleteResponse = deleteResponse =restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);