ES CURD

1. 创建

POST /accounts/person/1
{
  "name":"caimengzhi",
  "sex":"male",
  "job": "SA and Linux"
}
curl -XPOST 'master:9200/accounts/person/2' -d '
{
  "name":"jack",
  "sex":"male",
  "job": "SA and Linux"
}

详细操作过程
cmz@master:~$ curl -XPOST 'master:9200/accounts/person/2' -d '
> {
>   "name":"jack",
>   "sex":"male",
>   "job": "SA and Linux"
> }
> '
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 1,
    "result": "created",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "created": true
}

cmz@master:~$ curl -XGET 'master:9200/accounts/person/2'
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 1,
    "found": true,
    "_source": {
        "name": "jack",
        "sex": "male",
        "job": "SA and Linux"
    }
}

2. 查找

get accounts/person/1
curl -XGET 'master:9200/accounts/person/2'

详细操作过程
cmz@master:~$ curl -XGET 'master:9200/accounts/person/2'
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 2,
    "found": true,
    "_source": {
        "doc": {
            "job": "CEO and CTO"
        }
    }
}

3. 更新

POST /accounts/person/1/_update
{
  "doc":{
    "job": "CEO and CTO"
  }
}
curl -XPOST 'master:9200/accounts/person/2' -d '
{
  "doc":{
    "job": "CEO and CTO"
  }
}'
详细操作过程
cmz@master:~$ curl -XPOST 'master:9200/accounts/person/2' -d '
> {
>   "doc":{
>     "job": "CEO and CTO"
>   }
> }
> '
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 2,
    "result": "updated",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    },
    "created": false
}   
cmz@master:~$ curl -XGET 'master:9200/accounts/person/2'
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 2,
    "found": true,
    "_source": {
        "doc": {
            "job": "CEO and CTO"
        }
    }
}

4. 删除

DELETE accounts/person/2
curl -XDELETE 'master:9200/accounts/person/2'

详细操作过程
cmz@master:~$ curl -XDELETE 'master:9200/accounts/person/2'
{
    "found": true,
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "_version": 3,
    "result": "deleted",
    "_shards": {
        "total": 2,
        "successful": 2,
        "failed": 0
    }
}
cmz@master:~$ curl -XGET 'master:9200/accounts/person/2'
{
    "_index": "accounts",
    "_type": "person",
    "_id": "2",
    "found": false
}   

5. kibana界面操作

kibana界面操作