1598361308173

3.6 文档的操作

文档在ES服务中的唯一标识,_index, _type, _id三个内容为符合,锁定一个文档,操作是添加还是修改操作.

3.6.1 新建文档

自动生成id

# 添加文档,自动生成id
POST /book/novel
{
    "name":"盘龙",
    "author":"我吃西红柿",
    "count":100000,
    "on-sale":"2020-01-01",
    "dercr":"xixiixhh233333"
}

手动指定id

1598427829079

# 添加文档,手动指定id
POST /book/novel
{
    "name":"红楼梦",
    "author":"曹雪芹",
    "count":10890000,
    "on-sale":"1089-01-01",
    "dercr":"xixmeinviixh56733"
}

3.6.2 修改文档

覆盖式修改

# 添加文档,手动指定id
POST /book/novel
{
    "name":"红楼梦",
    "author":"曹雪芹",
    "count":10890078,
    "on-sale":"1089-03-01",
    "dercr":"xixmeinviixh56733"
}

doc修改方式(推荐使用)

# 修改文档,基于doc方式
POST /index/novel/1/_update
{
    "doc":{
        "count":"1235207200"
    }
}

1598427977878

3.6.3 删除文档

# 根据id删除文档
DELETE /book/novel/_id


results matching ""

    No results matching ""