elasticsearch RESTFUL Api 操作

elasticsearch RESTFUL Api 操作

method url desc
put http://localhost:9200/索引名称/类型名称/文档id 修改文档(字段覆盖)
post http://localhost:9200/索引名称/类型名称/文档id 创建文档
post http://localhost:9200/索引名称/类型名称/文档id/_update 更新文档(不覆盖)
post http://localhost:9200/索引名称/类型名称/_search 查询文档
get http://localhost:9200/索引名称/类型名称/文档id 查询文档
delete http://localhost:9200/索引名称/类型名称/文档id 删除文档

创建索引

PUT /test

PUT /test (创建一个test索引, 也可以称为数据库)
{
  "mappings":{
    "properties":{
      "name": {
        "type": "text"
      },
      "age": {
        "type": "text"
      },
      "hobby":{
        "type":"text"
      }
    }
  }
}

elasticsearch RESTFUL Api 操作_第1张图片
查看一下:

elasticsearch RESTFUL Api 操作_第2张图片

删除索引

DELETE /test

创建文档

POST /test/user/1 (其中 test是索引(数据库),user(表))

elasticsearch RESTFUL Api 操作_第3张图片

查询文档

GET /test/user/1

elasticsearch RESTFUL Api 操作_第4张图片

PUT方式修改文档

PUT /test/user/1

PUT /test/user/1
{
  "name": "xiao reiver",
  "age":23,
  "hobby":[
    "ball",
    "run"
    ]
}

elasticsearch RESTFUL Api 操作_第5张图片

查询一下:

elasticsearch RESTFUL Api 操作_第6张图片

post方式修改

POST /test/user/1/_update

POST /test/user/1/_update
{
  "doc":{
    "name": "big river",
    "age": 18
  }
}

elasticsearch RESTFUL Api 操作_第7张图片

删除文档

DELETE /test/user/1

elasticsearch RESTFUL Api 操作_第8张图片

查询一下:

elasticsearch RESTFUL Api 操作_第9张图片

你可能感兴趣的:(elasticsearch RESTFUL Api 操作)