es之java搜索文档
1:搜索文档数据(单个索引)
@Testpublic void getSingleDocument(){
GetResponse response = client.prepareGet("twitter", "tweet", "1").get();
System.out.println(response.toString());
}
2:搜索文档数据(多个索引)
@Testpublic 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);
}
}
}
以上是 es之java搜索文档 的全部内容, 来源链接: utcz.com/z/390928.html