美文网首页
13、分布式文档系统_document的_source元数据以及

13、分布式文档系统_document的_source元数据以及

作者: 拉提娜的爸爸 | 来源:发表于2019-12-29 16:53 被阅读0次

    1、_source元数据

    查看示例:

    ----------------------------------保存数据------------------------------------------
    PUT /test_index/test_type/1
    {
      "test_field1": "test field1",
      "test_field2": "test field2"
    }
    ----------------------------------保存数据------------------------------------------
    GET /test_index/test_type/1
    ----------------------------------查询结果------------------------------------------
    {
      "_index": "test_index",
      "_type": "test_type",
      "_id": "1",
      "_version": 1,
      "found": true,
      "_source": {
        "test_field1": "test field1",
        "test_field2": "test field2"
      }
    }
    

    _source元数据:就是说,我们在创建一个document的时候,使用的那个放在request body中的json串,默认情况下,在get的时候,会原封不动的给我们返回回来。

    2、_source定制返回结果

    定制返回的结果,指定_source中,返回哪些field

    ----------------------------------_source查询数据-------------------------------
    GET /test_index/test_type/1?_source=test_field2
    ----------------------------------查询结果------------------------------------------
    {
      "_index": "test_index",
      "_type": "test_type",
      "_id": "1",
      "_version": 1,
      "found": true,
      "_source": {
        "test_field2": "test field2"
      }
    }
    ----------------------------------------------------------------------------------------
    ----------------source多个field查询,field之间用逗号隔开----------------
    GET /test_index/test_type/1?_source=test_field2,test_field1
    ----------------------------------查询结果------------------------------------------
    {
      "_index": "test_index",
      "_type": "test_type",
      "_id": "1",
      "_version": 1,
      "found": true,
      "_source": {
        "test_field1": "test field1",
        "test_field2": "test field2"
      }
    }
    

    相关文章

      网友评论

          本文标题:13、分布式文档系统_document的_source元数据以及

          本文链接:https://www.haomeiwen.com/subject/keoyoctx.html