es之java搜索文档
@Test public void getSingleDocument(){ GetResponse response = client.prepareGet("twitter", "tweet", "1").get(); System.out.println(response.toString()); }
@Test public void getMutileDocument(){ MultiGetResponse multiGetResponse = client.prepareMultiGet() .add("twitter1" , "tweet" , "1") .add("twitter2" , "tweet" , "1") .add("twitter3" , "tweet" , "1") .add("twitter4" , "tweet" , "1","2","3") .get(); for (MultiGetItemResponse itemResponse : multiGetResponse) { GetResponse response = itemResponse.getResponse(); if (response.isExists()) { String sourceAsString = response.toString(); System.out.println(sourceAsString); } } }