Shell
# 创建索引 curl -XPUT http://localhost:9200/user?pretty -H 'Content-Type: application/json' -d ' { "settings" : { "index.number_of_shards" : 1, "index.number_of_replicas" : 0 } }' # 添加 curl -XPOST 'http://localhost:39200/user/_doc?pretty' -H 'Content-Type: application/json' -d ' { "user": "elastic", "message": "Hello World" }' # 添加或更新 curl -XPUT 'http://localhost:39200/user/_doc/1?pretty' -H 'Content-Type: application/json' -d ' { "user": "elastic1", "message": "Hello World" }' # 局部更新(指定条件) curl -XPOST 'http://localhost:39200/user/_doc/1/_update?pretty' -H 'Content-Type: application/json' -d ' { "doc": { "user": "elastic10" } }' "detect_noop": false # 无论当前的文档是否与doc中定义的相同,都会把doc合并到文档中 "result" : "updated" # 如果使用doc,那么会自动合并到现有的文档中 "result" : "noop" # 如果doc中定义的部分与现在的文档相同,则默认不会执行任何动作
================================================
创建索引
http://192.168.24.188:9200/people
settings : 修改分片和副本数
mappings : 修改字段和类型
number_of_replicas 数据备份数
number_of_shards 数据分片数