amazon-elasticsearch,Amazon Web Services,amazon Elasticsearch" /> amazon-elasticsearch,Amazon Web Services,amazon Elasticsearch" />

Amazon web services 在aws elasticsearch中插入json文件时出错

Amazon web services 在aws elasticsearch中插入json文件时出错,amazon-web-services,amazon-elasticsearch,Amazon Web Services,amazon Elasticsearch,我有一个小json文件,我在elasticsearch中使用t2实例,但我无法在aws elasticsearch中插入数据 我的文件如下所示 [{"Company_Name": "11 plc (NGSE:MOBIL)", "Business_Description": "11 plc markets petroleum products in Nigeria."}, {"Company_Name": "3Power Energy Group, Inc. (OTCPK:PSPW)", "Bus

我有一个小json文件,我在elasticsearch中使用t2实例,但我无法在aws elasticsearch中插入数据

我的文件如下所示

[{"Company_Name": "11 plc (NGSE:MOBIL)", "Business_Description": "11 plc markets petroleum products in Nigeria."}, {"Company_Name": "3Power Energy Group, Inc. (OTCPK:PSPW)", "Business_Description": "3Power Energy Group, Inc. focuses on developing, building, and operating power plants."}, {"Company_Name": "4Sight Holdings Limited (JSE:4SI)", "Business_Description": "4Sight Holdings Limited, through its subsidiaries, provides technology support solutions across various industries in Mauritius."}, {"Company_Name": "A'ayan Leasing and Investment Company K.S.C.P. (KWSE:AAYAN)", "Business_Description": "A'ayan Leasing and Investment Company K.S.C.P. engages in financial investments, trading and investing in properties"}]
我已尝试使用以下命令

curl -s -XPOST https://elasticsearchdomain/_bulk?pretty -H "Content-Type: application/x-ndjson" --data-binary '@data.json'
我得到状态400错误

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "The bulk request must be terminated by a newline [\\n]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "The bulk request must be terminated by a newline [\\n]"
  },
  "status" : 400
}

我做错了什么?

弹性搜索中的批量API没有达到您期望的效果。批量API用于在一个API调用中执行多个操作(例如索引、更新、删除)。因此,您必须指定要执行的特定操作类型。在这种情况下,您希望为多个文档编制索引:

curl-X POST“localhost:9200/_bulk?pretty”-H'内容类型:application/json'-d”
{“索引”:{“索引”:“我的索引”,“索引id”:“1”}
{“公司名称”:“11 plc(NGSE:MOBIL)”,“业务描述”:“11 plc在尼日利亚销售石油产品。”
{“索引”:{“索引”:“我的索引”,“索引id”:“2”}
{“公司名称”:“3Power Energy Group,Inc.(OTCPK:PSPW)”,“业务描述”:“3Power Energy Group,Inc.专注于发电厂的开发、建设和运营。”
'

因此,对于每个文档,您都要指定操作(本例中为索引),通过换行符终止操作,然后再次指定文档(通过换行符终止)。

是否有任何函数可以将我的json文件索引为所需的json格式(使用inxdexing)?