英文:
ElasticSearch Bulk Load failure
问题
这是我得到的错误信息:
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [create] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [create] for create index"
},
"status": 400
}
请问有人能告诉我我在哪里出错了以及如何修复这个问题吗?
英文:
I am learning ElasticSearch and trying to do bulk upload using a json file but unfortunately it fails with a parse exception.
Here is my Curl Command Looks like (I am using Postman, I copied this command for reference)
curl --location --request PUT '127.0.0.1:9200/_bulk ' \
> --header 'Content-Type: application/json' \
> --data '@/Users/themis/Downloads/ml-latest-small/movies.json'
This is my json file,
> `{ "create" : { "_index" : "movies", "_id" : "135569" } } { "id":
> "135569", "title" : "Star Trek Beyond", "year":2016 ,
> "genre":["Action", "Adventure", "Sci-Fi"] } { "create" : { "_index" :
> "movies", "_id" : "122886" } } { "id": "122886", "title" : "Star Wars:
> Episode VII - The Force Awakens", "year":2015 , "genre":["Action",
> "Adventure", "Fantasy", "Sci-Fi", "IMAX"] } { "create" : { "_index" :
> "movies", "_id" : "109487" } } { "id": "109487", "title" :
> "Interstellar", "year":2014 , "genre":["Sci-Fi", "IMAX"] } { "create"
> : { "_index" : "movies", "_id" : "58559" } } { "id": "58559", "title"
> : "Dark Knight, The", "year":2008 , "genre":["Action", "Crime",
> "Drama", "IMAX"] } { "create" : { "_index" : "movies", "_id" : "1924"
> } } { "id": "1924", "title" : "Plan 9 from Outer Space", "year":1959 ,
> "genre":["Horror", "Sci-Fi"] } `
Here is the error I got:
`{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "unknown key [create] for create index"
}
],
"type": "parse_exception",
"reason": "unknown key [create] for create index"
},
"status": 400
}`
Can someone please point me where I am doing mistake and how do I fix that?
答案1
得分: 2
你的调用试图创建一个名为 _bulk
的索引(即 PUT 操作),提示:未知的键 [create] 用于 **创建索引**
。
你需要使用 POST 而不是 PUT 来使用 _bulk
API。
curl --location --request POST '127.0.0.1:9200/_bulk'
英文:
Your call is trying to create an index (i.e. PUT) called _bulk
(hint: unknown key [create] for **create index**
)
You need to use POST and not PUT with the _bulk
API
curl --location --request POST '127.0.0.1:9200/_bulk' \
^^
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论