restful 风格操作es 学习

文章封面

restful 风格操作es

method url地址 描述
PUT host:port/索引名/类型名/文档ID 创建文档(指定文档ID)
POST host:port/索引名/类型名 创建文档(随机文档ID)
POST host:port/索引名/类型名/文档ID/_update 修改文档
POST host:port/索引名/类型名/文档ID/_search 查询数据
DELETE host:port/索引名[/类型名][/文档ID] 删除文档
GET host:port/索引名/类型名/文档ID 通过文档ID查询文档

类型:_doc

PUT

创建一个文档

PUT /test/_doc/doc1
{
    "name":"test"
}

image-20220106164558013

更新文档

PUT /test/_doc/doc1
{
    "name":"更新测试"
}

image-20220106172051965

指定数据类型创建索引

数据类型 关键字
字符串 text keyword(不可分词)
数值 long integer short byte double float (half float) (scaled float)
日期 date
布尔 boolean
PUT /test1
{
    "mappings" : {
        "properties" : {
            "name" : {
                "type" : "keyword"
            }            
        }
    }
}

image-20220106165647716

GET

获取索引信息

 GET test1

image-20220106170007996

获取健康值

GET _cat/health

image-20220106170814673

GET _cat/indices?v

image-20220106170921309

POST

更新文档

POST /test/_doc/doc1/_update
{
    "doc" : {
        "name":"更新1测试"
    }
}

image-20220106172205021

评论

暂无评论