我正在尝试在elasticsearch中加载json文件。我首先使用XPUT创建索引,如下所示 -
curl -XPUT 'localhost:9200/project5' -d @med.json
我正在尝试使用以下命令从
加载json文件中的数据curl -XPOST 'localhost:9200/project5/_search' -d @med.json '{"query":{"match_all":{}},"size":100}'
但它给了我这个错误 -
{"error":"SearchPhaseExecutionException[Failed to execute phase [query],all shards failed; shardFailures {[B3acaOD7SauK8bRWlX24vQ][project5][4]: SearchParseException[[project5][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{ \"media_type\": \"game\", \"title\": \"Final Fantasy VI\", \"year\": \"1994\"}]]];
nested: SearchParseException[[project5][4]: from[-1],size[-1]: Parse Failure [No parser for element [media_type]]]; }{[B3acaOD7SauK8bRWlX24vQ][project5][1]: SearchParseException[[project5][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{ \"media_type\": \"game\", \"title\": \"Final Fantasy VI\", \"year\": \"1994\"}]]];
nested: SearchParseException[[project5][1]: from[-1],size[-1]: Parse Failure [No parser for element [media_type]]]; }{[B3acaOD7SauK8bRWlX24vQ][project5][0]: SearchParseException[[project5][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{ \"media_type\": \"game\", \"title\": \"Final Fantasy VI\", \"year\": \"1994\"}]]]; curl: (3) [globbing] nested braces not supported at pos 10
nested: SearchParseException[[project5][0]: from[-1],size[-1]: Parse Failure [No parser for element [media_type]]]; }{[B3acaOD7SauK8bRWlX24vQ][project5][3]: SearchParseException[[project5][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{ \"media_type\": \"game\", \"title\": \"Final Fantasy VI\", \"year\": \"1994\"}]]];
nested: SearchParseException[[project5][3]: from[-1],size[-1]: Parse Failure [No parser for element [media_type]]]; }{[B3acaOD7SauK8bRWlX24vQ][project5][2]: SearchParseException[[project5][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{ \"media_type\": \"game\", \"title\": \"Final Fantasy VI\", \"year\": \"1994\"}]]];
nested: SearchParseException[[project5][2]: from[-1],size[-1]: Parse Failure [No parser for element [media_type]]]; }]","status":400}
我的json文件如下 -
{
"media_type":"game",
"title":"Final Fantasy VI",
"year":"1994"
},
{
"media_type":"book",
"title":"Harry Potter",
"year":"2010"
},
{
"media_type":"music",
"title":"Surfing With The Alien",
"year":"1987"
}
你能帮帮忙吗?提前谢谢!
答案 0 :(得分:0)
从查询中删除@med.json
。您的查询应该如下:
curl -XPOST 'localhost:9200/project5/_search' -d '{"query":{"match_all":{}},"size":100}'
例如,请参阅this。