Get API

作者: 风云傲天 | 来源:发表于2018-11-15 21:07 被阅读0次

测试数据

PUT twitter
{
   "mappings": {
      "_doc": {
         "properties": {
            "id": {
               "type": "integer",
               "store": true
             },
            "counter": {
               "type": "integer",
               "store": false
            },
            "tags": {
               "type": "keyword",
               "store": true
            }
         }
      }
   }
}
PUT twitter/_doc/1
{
    "id": 1,
    "counter" : 10,
    "tags" : ["red"]
}
PUT twitter/_doc/2?routing=user1
{
    "id": 1,
    "counter" : 10,
    "tags" : ["red"]
}
  • 不获取source
    GET twitter/_doc/1?_source=false
  • 过滤source
    GET twitter/_doc/1?_source_include=*.id&_source_exclude=tags
  • 只获取指定的stored字段
    GET twitter/_doc/1?stored_fields=tags,counter
  • 只获取_source
    GET twitter/_doc/1/_source
  • 获取指定routing下的stored字段
    GET twitter/_doc/2?routing=user1&stored_fields=id,tags
  • 查询前先刷新对应的shards: refresh=true
    使用需谨慎,会导致性能下降
    GET twitter/_doc/1?refresh=true
  • 获取指定version的文档
    GET twitter/_doc/1?version=1

相关文章

网友评论

      本文标题:Get API

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