windows 下 curl 操作 es

//查询index  topic123
curl -H "Content-Type: application/json" -XPOST localhost:9200/topic123/_search?pretty

//创建索引
curl -XPUT "http://localhost:9200/people?include_type_name=true" -H "Content-Type:application/json" -d "{\"settings\":{\"index.number_of_shards\":3,\"index.number_of_replicas\":1},\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"},\"age\":{\"type\":\"integer\"}}}}}"

//插入数据
curl -XPUT "http://localhost:9200/people/_doc/1" -H "Content-Type:application/json" -d "{\"name\":\"zhangsan\",\"age\": 21}"


//查询数据
curl -XGET "http://localhost:9200/people/_doc/1"

windows 下 执行 curl 命令 如果命令中包含 json字符串,字符串中 双引号 需要加 转义
-d 后 第一个双引号 不加转义
最后一个双引号 不加转义

调用git 命令行执行 避免以上问题,dos下不支持多行输入,调用git命令行可以多行输入

在这里插入图片描述

例子参考

curl -XPUT http://localhost:9200/bigdata_p 

curl -H "Content-Type: application/json" -XPOST http://localhost:9200/bigdata_p/product/ -d '{"author" : "Doug Cutting"}' 

curl -H "Content-Type: application/json" -XPOST http://localhost:9200/bigdata_p/product/ -d '{"name":"hadoop","author":"Doug Cutting","c_version":"2.7.3"}' 
curl -XGET http://localhost:9200/bigdata_p/_search?pretty 
curl -XGET http://localhost:9200/bigdata_p/product/_search?pretty 

curl -XGET http://localhost:9200/bigdata_p/product/1?pretty 

curl -XGET http://localhost:9200/bigdata_p/product/1?_source=name&pretty 
curl -XGET http://localhost:9200/bigdata_p/product/1?_source=name,author&pretty
curl -XGET http://localhost:9200/bigdata_p/product/1?_source&pretty 


curl -H "Content-Type: application/json" -XGET http://localhost:9200/_search?pretty -d '
{
  "query": {
    "multi_match": {
      "type":     "most_fields", 
      "query":    "111",
      "fields": [ "title", "title.english" ]
    }
  }
}'
http://127.0.0.1:9200/_cat/indices?v

https://127.0.0.1:9200/topic123/_search?pretty


curl http://127.0.0.1:9200/topic123/_search?pretty

http://127.0.0.1:9200/_cat/indices?v

curl -H "Content-Type: application/json" -XPOST localhost:9200/topic123/_search?pretty

curl -XPUT "http://localhost:9200/people?include_type_name=true" -H "Content-Type:application/json" -d "{\"settings\":{\"index.number_of_shards\":3,\"index.number_of_replicas\":1},\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"},\"age\":{\"type\":\"integer\"}}}}}"

curl -XPUT "http://localhost:9200/people/_doc/1" -H "Content-Type:application/json" -d "{\"name\":\"zhangsan\",\"age\": 21}"

curl -XGET "http://localhost:9200/people/_doc/1"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值