ElasticSearch Index API

来源:互联网 发布:淘宝衣服评价语20字 编辑:程序博客网 时间:2024/05/16 07:48

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.
上面的这个指令会自动创建索引和类型,如果他们不存在,创建应该是使用默认的配置,不过我们可以手动创建索引和type。

另外下面还可以有个版本控制:

curl-XPUT'localhost:9200/twitter/tweet/1?version=2'-d'{"message":"elasticsearch now has versioning support, double cool!"}'






0 0
原创粉丝点击