elasticsearch 的post put 方式的对比 setting mapping设置

智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述elasticsearch 的post put 方式的对比 setting mapping设置相关的知识,希望能为你提供帮助。
1.POST和PUT都可以用于创建
2.PUT是幂等方法,POST不是。所以post用户更新,put用于新增比较合适。 
参考:https://yq.aliyun.com/articles/366099

https://www.bbsmax.com/A/xl56bqb15r/      curl -XGET  http://192.168.79.131:9200/shb01/_settings?pretty    curl -XPUT http://192.168.79.131:9200/shb03-d\'{"settings":{"number_of_shards":4,"number_of_replicas":2}}\'
----------------------------------------------------------------------------------------------------------------------
1.post

curl -XPOST http://192.168.1.49:9200/test/user/1\\ -H \'cache-control: no-cache\' \\ -H \'content-type: application/json\'-d \'{"name" : "john" }\'==> 指定id
----------------------------------------------------

【elasticsearch 的post put 方式的对比 setting mapping设置】 curl -XPOST http://192.168.1.49:9200/test/user/11 \\
-H \'cache-control: no-cache\' \\
-H \'content-type: application/json\'  -d \'{"name" : "john" }\'
非幂等性,可以用来修改记录 ---------------------------------------------------- curl -XPOST http://192.168.1.49:9200/test/user\\ -H \'cache-control: no-cache\' \\ -H \'content-type: application/json\'-d \'{"name" : "john"}\' 不指定id,自动生成

2.put
curl -XPUT http://192.168.1.49:9200/test/user/22/_create-H \'cache-control: no-cache\'-H \'content-type: application/json{"name" : "john" }\' 指定id ------------------------------------------------------幂等性,不能重复操作 curl -XPUT http://192.168.1.49:9200/test/user/22/_create-H \'cache-control: no-cache\'-H \'content-type: application/json{"name" : "john222" }\'
version conflict, document already exists

 

    推荐阅读