智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述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
推荐阅读
- android 关联某些后缀使用app打开
- Android studio之广播监听接收短信
- 二十二(视图之add_url_rule和app.route)
- Android Studio采坑记录
- 分析SAN LUN Mapping出错导致文件系统共享冲突的情况
- android修改默认输入法
- Appium 环境配置
- ACCT648 Applied Statistics for Data Analysis
- SpringBoot配置文件application.properties数据库配置