ElasticSearch提供了根据索引名称,类别,文档ID来获取数据
@Test public void testGet(){ GetResponse getResponse=client.prepareGet("twitter", "tweet", "1").get(); System.out.println(getResponse.getSourceAsString()); }
返回结果{"user":"kimchy","postDate":"2017-09-11T08:28:50.455Z","message":"trying out Elasticsearch"}
是个json串,我们可以用Json工具框架搞成对象,方便提取属性;