上传 Json 文件时,为什么 Elasticsearch 中的 docs.count=0?
Why is docs.count=0 in Elasticsearch, when uploading a Json-file?
我有一个 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" 的索引,所以我用谷歌搜索,有人说这可能是因为 Elasticsearch 中没有任何文档。
所以我查看了 Management-Elasticsearch 部分,确实 "docs count" 为零。
现在的问题是:如何让 Elasticsearch/Kibana 正确地从文件中读取我的数据?接受映射以及索引。
我只是不明白,为什么 "results" 没有被视为文档。我的文件中是否必须有其他结构?
感谢任何帮助!
谢谢转发。
您在哪里复制了批量命令? header 部分是错误的。
我也从未见过 es 转储中的映射子句。你确定这可能吗?
根据 documentation
- here:
- 您应该为索引创建映射
- 然后你创建一个 json 转储 - 看看 here for json format guide, and here 你可以看看 wikipedia 生产 elasticsearch 转储的格式
然后你索引你的转储,根据 documentation 的 curl bulk 命令是:
curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test2.json"; echo
我有一个 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" 的索引,所以我用谷歌搜索,有人说这可能是因为 Elasticsearch 中没有任何文档。
所以我查看了 Management-Elasticsearch 部分,确实 "docs count" 为零。
现在的问题是:如何让 Elasticsearch/Kibana 正确地从文件中读取我的数据?接受映射以及索引。 我只是不明白,为什么 "results" 没有被视为文档。我的文件中是否必须有其他结构?
感谢任何帮助! 谢谢转发。
您在哪里复制了批量命令? header 部分是错误的。
我也从未见过 es 转储中的映射子句。你确定这可能吗?
根据 documentation
- here:
- 您应该为索引创建映射
- 然后你创建一个 json 转储 - 看看 here for json format guide, and here 你可以看看 wikipedia 生产 elasticsearch 转储的格式
然后你索引你的转储,根据 documentation 的 curl bulk 命令是:
curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test2.json"; echo