{
“_index”:“twitter”,
“_type”:“_doc”,
“_id”:“1”,
“_version”:3,
“found”:true
}
不符合预期,这是为什么呢?将在下文给出答案。
3、示例三:使用fetchSourceContext进行字段的过滤
public static void testGet_fetchSourceContext() {
RestHighLevelClient client = EsClient.getClient();
try {
GetRequest request = new GetRequest(“twitter”, “_doc”, “1”);
= new String[]{“message”, “*date”};
FetchSourceContext fsc = new FetchSourceContext(true, includes, null);
request.fetchSourceContext(fsc);
GetResponse result = client.get(request, RequestOptions.DEFAULT);
System.out.println(result);
} catch(Throwable e) {
e.printStackTrace();
} finally {
EsClient.close(client);
}
}
返回结果:
{
“_index”:“twitter”,
“_type”:“_doc”,
“_id”:“1”,</