ElasticSearch 常用命令

1.创建索引

PUT users
{
  "mappings": {
    "properties": {
      "name":{
        "type": "keyword"
      },
      "age":{
        "type": "integer"
      },
      "remark":{
        "type": "text"
      }
    }
  }
}

2.添加索引结构

PUT users/_mapping
{
  "properties": {
      "content1":{
        "type": "keyword"
      },
      "content2":{
        "type": "keyword"
      }
  }
}

3.查看索引结构

GET users

4.删除索引

DELETE users

1.添加(文档)数据

PUT users/_doc/1
{
  "age":15,
  "name":"张三的名字叫张三",
  "remark":"张三的备注",
  "content":"张三的content"
}

2.根ID获得文档数据

GET users/_doc/1

3.根据ID修改文档数据(post方式,推荐)


POST users/_doc/1
{
  "doc":{
    "age":15,
    "name":"张三的名字",
    "remark":"张三的备注"
  }
}

4.根据ID删除

DELETE users/_doc/1
上一篇
下一篇