Elasticsearch中,一条index被成为一条document,每条document以json格式存在
创建一条记录(document)
添加一条记录到twitter的user type中,id=1
curl -XPOST 'http://localhost:9200/twitter/user/1' -d'
{
"username":"xiaoming"
}'
可以不指定id,那么会自动生成一个随机的id
返回结果:
{
"_index" : "twitter",
"_type" : "user",
"_id" : "1",
"_version" : 3,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : false
}
当没有此id的document时,插入后created=true,
当插入已存在的id时,插入后created=false,version的值会加1,elasticsearch中,当对同一个id更新的时候,会创建新的一个version,每个version保存着不同的版本数据
插入document时创建index
如果不存在index,会在插入的时候自动创建index
如果不存在type, 会在插入的时候自动创建type
关闭自动创建index
action.auto_create_index=false
关系自动创建mpping
index.mapper.dynamic = false