响应包含了现在熟悉的元数据节点,增加了_source字段,它包含了在创建索引时我们发送给Elasticsearch的原始文档。

    1. {
    2. "_index" : "website",
    3. "_type" : "blog",
    4. "_id" : "123",
    5. "_version" : 1,
    6. "found" : true,
    7. "_source" : {
    8. "title": "My first blog entry",
    9. "text": "Just trying this out...",
    10. "date": "2014/01/01"
    11. }

    此外,HTTP响应状态码也会变成'404 Not Found'代替'200 OK'。我们可以在curl后加-i参数得到响应头:

    现在响应类似于这样:

    1. HTTP/1.1 404 Not Found
    2. Content-Type: application/json; charset=UTF-8
    3. Content-Length: 83
    4. {
    5. "_index" : "website",
    6. "_type" : "blog",
    7. "_id" : "124",
    8. "found" : false
    9. }

    检索文档的一部分

    _source字段现在只包含我们请求的字段,而且过滤了date字段:

    1. {
    2. "_type" : "blog",
    3. "_id" : "123",
    4. "_version" : 1,
    5. "exists" : true,
    6. "_source" : {
    7. "title": "My first blog entry" ,
    8. "text": "Just trying this out..."
    9. }
    10. }

    或者你只想得到_source字段而不要其他的元数据,你可以这样请求:

    1. {
    2. "title": "My first blog entry",
    3. "text": "Just trying this out...",