我有一个JSON文件(test2.json),其数据如下所示:
{"index":{"_index":"wiki","_type":"data","_id":1},
"mappings": {
"doc": {
"properties": {
"curr": {"type": "text"},
"n": {"type": "integer"},
"prev": {"type": "text"},
"type": {"type": "text"}
}
}
}
}
{
"results": [
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 43,
"prev": "other-external",
"type": "external"
}
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 1569,
"prev": "other-search",
"type": "external"
}
{
"curr": "Ohio_\"Heartbeat_Bill\"",
"n": 11,
"prev": "other-internal",
"type": "external"
}
]
}
我使用以下命令将此数据输入到Elasticsearch中:
curl elastic:elastic@localhost:9200/wiki -H "Content-type: application/json" -X PUT -d @test2.json
当我在Kibana中打开“管理”时,找不到任何名为“wiki”的索引,因此我用Google搜索,有人说这可能是由于Elasticsearch中没有任何文档。
因此,我查看了“管理- flex 搜索”部分,真正的“文档数”为零。
现在的问题是:如何让Elasticsearch / Kibana从文件中正确读取数据?接受映射以及索引。
我只是不明白,为什么“结果”不被视为文档。我的文件中是否必须具有其他结构?
任何帮助表示赞赏!
谢谢你向前。
最佳答案
您在何处复制了批量命令? header 部分错误。
我从未见过es转储中的映射子句。您确定有可能吗?
根据documentation
-here:
curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test2.json"; echo
关于json - 上载Json文件时,为什么Elasticsearch中的docs.count = 0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54325795/