响应包含了现在熟悉的元数据节点,增加了_source
字段,它包含了在创建索引时我们发送给Elasticsearch的原始文档。
{
"_index" : "website",
"_type" : "blog",
"_id" : "123",
"_version" : 1,
"found" : true,
"_source" : {
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/01"
}
此外,HTTP响应状态码也会变成'404 Not Found'
代替'200 OK'
。我们可以在curl
后加-i
参数得到响应头:
现在响应类似于这样:
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=UTF-8
Content-Length: 83
{
"_index" : "website",
"_type" : "blog",
"_id" : "124",
"found" : false
}
检索文档的一部分
_source
字段现在只包含我们请求的字段,而且过滤了date
字段:
{
"_type" : "blog",
"_id" : "123",
"_version" : 1,
"exists" : true,
"_source" : {
"title": "My first blog entry" ,
"text": "Just trying this out..."
}
}
或者你只想得到_source
字段而不要其他的元数据,你可以这样请求:
{
"title": "My first blog entry",
"text": "Just trying this out...",