弹性搜索主体索引api通过休息终点 [英] Elasticsearch bulk index api via rest endpoint

查看:104
本文介绍了弹性搜索主体索引api通过休息终点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的要求:

POST /_bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{"firstname":"first_name1","lastname":"last_name1"},
{"firstname":"first_name2","lastname":"last_name2"},
{"firstname":"first_name3","lastname":"last_name3"}}

这是错误:


{    "error": "IllegalArgumentException[Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found

[VALUE_STRING]],状态:500}

[VALUE_STRING]]", "status": 500 }

基本上,每个文档都是{firstname:___, lastname:____}我不想将它们包装到父字段中。我从根本上缺少什么?

Basically, each document is {"firstname": ___, "lastname": ____} I don't want to wrap them into a parent field. What am I fundamentally missing?

推荐答案

您只是缺少第二和第三个文档的操作行,尝试如下:

You're simply missing an action line for the second and third documents, try like this:

POST /_bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{"firstname":"first_name1","lastname":"last_name1"}
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{"firstname":"first_name2","lastname":"last_name2"}
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{"firstname":"first_name3","lastname":"last_name3"}

这篇关于弹性搜索主体索引api通过休息终点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆