我正在学习ElasticSearch,并尝试使用JSON文件进行批量上传,但不幸的是,它失败了,出现了解析异常。
这是我的 curl 命令看起来像(我用 Postman ,我复制了这个命令作为参考)
curl --location --request PUT '127.0.0.1:9200/_bulk ' \
> --header 'Content-Type: application/json' \
> --data '@/Users/themis/Downloads/ml-latest-small/movies.json'
这是我的json文件
> `{ "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"] } `
下面是我得到的错误:
`{
"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
}`
有没有人能告诉我我在哪里犯了错误,我该怎么改正?
1条答案
按热度按时间hmmo2u0o1#
您的调用正在尝试创建一个名为
_bulk
的索引(即PUT)(提示:(x月1日至1x日)对于
_bulk
API,您需要使用POST而不是PUT