Index添加或者更新一种类型JSON文档在一个特定的索引,让它可以被搜索。比如下面,添加:
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}'
执行结果:
{ "_shards" : { "total" : 10, "failed" : 0, "successful" : 10 },
"_index" : "twitter", "_type" : "tweet", "_id" : "1", "_version" : 1, "created" : true}
-
total
- Indicates to how many shard copies (primary and replica shards) the index operation should be executed on. -
successful
- Indicates the number of shard copies the index operation succeeded on.成功successful至少为1 -
failures
- An array that contains replication related errors in the case an index operation failed on a replica shard.
另外下面还可以有个版本控制:
curl -XPUT 'localhost:9200/twitter/tweet/1?version=2' -d '{ "message" : "elasticsearch now has versioning support, double cool!"}'