json - 上载Json文件时,为什么Elasticsearch中的docs.count = 0?

标签 json elasticsearch kibana

我有一个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 搜索”部分,真正的“文档数”为零。

docs.count=0

现在的问题是:如何让Elasticsearch / Kibana从文件中正确读取数据?接受映射以及索引。
我只是不明白,为什么“结果”不被视为文档。我的文件中是否必须具有其他结构?

任何帮助表示赞赏!
谢谢你向前。

最佳答案

您在何处复制了批量命令? header 部分错误。
我从未见过es转储中的映射子句。您确定有可能吗?
根据documentation-here:

  • 您应该为索引
  • 创建映射
  • 然后创建一个json转储-查看jsont_a以获取json格式指南,然后here可以查看维基百科生产的Elasticsearch转储
  • 的格式
  • ,然后使用curl批量命令索引转储,该命令根据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/

    相关文章:

    elasticsearch - 弹性:我想写一个查询(在特定月份的任何时候,每小时经历的峰值量)

    php - 在 json 模式数据中包含 php 变量 - WordPress 站点 - 无效的 json 错误

    elasticsearch - Elasticsearch :多个查询和增强

    elasticsearch - 如何在cassandra上安装搜索引擎?

    elasticsearch - 从ElasticSearch读取数据时日期格式问题

    elasticsearch - 如何强制Elastic从 float 中保留更多小数

    python - 使用 JSON 序列化和反序列化对象

    javascript - 当某些内容来自其他 JSON 对象时,如何使用 orderBy 和过滤器

    ios - JSon 解析错误 IOS 对象键为空

    elasticsearch - 使用仪表板上的时间过滤器更改基巴纳州Vega的范围