首页 > 其他 > 详细

elasticsearch批量索引数据示例

时间:2015-09-30 12:37:04      阅读:341      评论:0      收藏:0      [点我收藏+]

      示例数据文件document.json(index表示在索引中增加或替换现有文档,create表示如果文档不存在则添加文档,delete表示删除文档):

{ "index": { "_index": "addr", "_type": "contact", "_id": 1 }}
{ "name": "Fyodor Dostoevsky", "country": "RU" }
{ "create": { "_index": "addr", "_type": "contact", "_id": 2 }}
{ "name": "Erich Maria Remarque", "country": "DE" }
{ "create": { "_index": "addr", "_type": "contact", "_id": 2 }}
{ "name": "Joseph Heller", country: "US" }
{ "delete": { "_index": "addr", "_type": "contact", "_id": 4 }}
{ "delete": { "_index": "addr", "_type": "contact", "_id": 1 }}

  

  执行语句:

  curl -XPOST ‘localhost:9200/_bulk?pretty‘ --data-binary  @document.json  

  注:可在_bulk端点前直接指定index或index和type,这样可在数据文件中省略这些属性,elasticsearch将使用默认值。

 

 

 

  

 

 

 

  

    

 

elasticsearch批量索引数据示例

原文:http://www.cnblogs.com/sheeva/p/4848718.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!