【问题标题】:elastic search _bulk request with "head" plugin带有“head”插件的弹性搜索_bulk请求
【发布时间】:2015-01-03 12:51:32
【问题描述】:

我有一个弹性搜索集群,并正确安装了"elasticsearch-head" 插件。

我想使用 _bulk API 一次插入多个值,但 _bulk 请求正文的特定格式似乎给插件带来了麻烦。

我使用“任何查询”面板通过以下设置指定我的请求:
查询:/_bulk
正文:

{ "create" : { "_index" : "eco", "_type" : "usage" } }
{ "index": 1, name" : "my_value" }

我在验证 json 时得到以下信息并且请求不会被执行:

JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data

有谁知道 elasticsearch-head 插件是否可以处理 _bulk API? 还是我的请求有问题?

【问题讨论】:

    标签: search bulk elasticsearch-plugin


    【解决方案1】:

    elasticsearch-head 插件不支持 _bulk,会导致 JSON 错误... 希望作者能尽快支持,大家可以向下面这个网站提交issue。 https://github.com/TravisTX/elasticsearch-head-chrome/issues

    【讨论】:

      【解决方案2】:

      您缺少名称前的引号。

      { "index": 1, "name" : "my_value" }

      【讨论】:

      【解决方案3】:

      现在 2021 年 9 月 27 日,ES 7.15.0。

      我尝试使用“head”插件发送_bulk,也失败了。

      但我发现使用 Postman 或 Curl 都可以。

      [PUT]http://localhost:9200/customer/external/_bulk

      // Postman > Body > raw > JSON
      {"index":{"_id":"1"}}
      {"name":"a"}
      {"index":{"_id":"2"}}
      {"name":"b"}
      
      

      通知

      • 让每个 json 语句保持在每一行,不要展开它们。
      • 您需要在底部有一个空行。

      使用 curl,您需要将语句保存在文件中,然后 @it:

      $ curl -XPUT 'http://localhost:9200/customer/external/_bulk' -H "Content-Type:application/json" --data-binary @esSQL.json
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-20
        • 2014-01-19
        • 2012-11-29
        • 1970-01-01
        • 1970-01-01
        • 2018-03-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多