zoukankan      html  css  js  c++  java
  • 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
    ----------------------------------------------------

    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
  • 相关阅读:
    杭电2042
    杭电2041
    杭电2040
    杭电2046
    SPOJ
    SPOJ
    SPOJ
    HDU
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/hixiaowei/p/11793494.html
Copyright © 2011-2022 走看看