开发者学堂课程【ElasticSearch 入门精讲:索引文档条数】学习笔记,与课程紧密连接,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/631/detail/9990
索引文档条数
ES JavaAPI 之索引文档条数
@Test
public void testCount() {
//该方法过时,请使用 prepareSearch
Longcount=client.prepareCount"bigdata").get().getCount();
System.out.println(count);
}
DeleteResponse response = client.prepareDelete(INDEX, TYPE, id: "0o-9q2oBAvDYwfvDRwhz") .get(); String result = "deleted".equals(response.getResult().toString().toLowerCase()) ? "恭喜!删除成功!"“抱歉!删除失败”; System. out.println("删除之后的反馈信息是: " + result); } *需求:测试获得指定的素引库中特定的 type 中 document 的条数 @Test public void testGetCount() { } client.prepareSearch( ..ndices: INDEX) SearchRequestBuilder .setTypes( TYPE) SearchRequestBuilder .execute() ActionFuture <SearchResponse> .actionGet() SearchResponse .getHits() SearchHits getTotalHits); System. out.println("查询到的总记录数是:"+totalHits); } @After public void cleanup() { System. out.println(""\n 后处理操作,用于资源的释放..."); if (client != null) { |