将数据索引到弹性搜索时出现批量API错误



我想使用批量API将一些数据导入到elasticsearch中。这是我使用Kibana开发工具创建的映射:

PUT /main-news-test-data
{
"mappings": {
"properties": {
"content": {
"type": "text"
},
"title": {
"type": "text"
},
"lead": {
"type": "text"
},
"agency": {
"type": "keyword"
},
"date_created": {
"type": "date"
},
"url": {
"type": "keyword"
},
"image": {
"type": "keyword"
},
"category": {
"type": "keyword"
},
"id":{
"type": "keyword"
}
}
}
}

这是我的批量数据:

{ "index" : { "_index" : "main-news-test-data", "_id" : "1" } }
{
"content":"u0641u0647u06ccu0645u0647 u062du0633u0646u200cu0645u06ccu0631u06cc: u0627u06afu0631u0686u0647 u062fu0631 u0647u06ccu0627u0647u0648u06cc ",
"title":"u06a9u0627u0631u0647u0627u06cc u0642u0627u0644u06ccu0628u0627u0641",
"lead":"u062cu0627u0645u0639u0647 > u0634u0647u0631u06cc -.",
"agency":"13",
"date_created":1494518193,
"url":"http://www.khabaronline.ir/(X(1)S(bud4wg3ebzbxv51mj45iwjtp))/detail/663749/society/urban",
"image":"uploads/2017/05/11/1589793661.jpg",
"category":"15",
"id":"2981643"
}
{ "index" : { "_index" : "main-news-test-data", "_id" : "2" } }
{ 
....

但是当我想发布数据时,我收到了这个错误:

{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]"
}
"status" : 400
}

问题出在哪里?我在Kibana开发工具中同时使用了PowerShell和POST方法,但在两者中都收到了相同的错误。

数据应该在一行中指定,如下所示:

{ "index" : { "_index" : "main-news-test-data", "_id" : "1" } }
{ "content":"u0641u0647","title":"u06a9" }

请参考此SO答案

请尝试以下批量JSON格式。我已经在本地测试了这个批量的API请求,现在它运行得很好:

{ "index" : { "_index" : "main-news-test-data", "_id" : "1" } }
{"content":"u0641u0647u06ccu0645u0647 u062du0633u0646u200cu0645u06ccu0631u06cc: u0627u06afu0631u0686u0647 u062fu0631 u0647u06ccu0627u0647u0648u06cc ", "title":"u06a9u0627u0631u0647u0627u06cc u0642u0627u0644u06ccu0628u0627u0641", "lead":"u062cu0627u0645u0639u0647 > u0634u0647u0631u06cc -.", "agency":"13", "date_created":1494518193, "url":"http://www.khabaronline.ir/(X(1)S(bud4wg3ebzbxv51mj45iwjtp))/detail/663749/society/urban", "image":"uploads/2017/05/11/1589793661.jpg", "category":"15", "id":"2981643"}

不要忘记在内容末尾添加一行

相关内容

  • 没有找到相关文章

最新更新