Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
elasticsearch批量插入JSON文件_Json_Search_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Bulkinsert - Fatal编程技术网 elasticsearch,bulkinsert,Json,Search,elasticsearch,Bulkinsert" /> elasticsearch,bulkinsert,Json,Search,elasticsearch,Bulkinsert" />

elasticsearch批量插入JSON文件

elasticsearch批量插入JSON文件,json,search,elasticsearch,bulkinsert,Json,Search,elasticsearch,Bulkinsert,我有以下几点 我使用awk来消除空白、尾随、下一行 awk -v ORS= -v OFS= '{$1=$1}1' data.json 我在data.json的顶部添加了一个create请求,后面是\n和我的其余数据 {"create": {"_index":"socteam", "_type":"products"}} 当我发出批量提交请求时,我得到以下错误 CURL -XPUT http://localhost:9200/_bulk { "took": 1, "errors":

我有以下几点

我使用awk来消除空白、尾随、下一行

awk -v ORS= -v OFS= '{$1=$1}1' data.json
我在data.json的顶部添加了一个create请求,后面是\n和我的其余数据

{"create": {"_index":"socteam", "_type":"products"}} 
当我发出批量提交请求时,我得到以下错误

CURL -XPUT http://localhost:9200/_bulk

{
  "took": 1,
  "errors": true,
  "items": [
    {
      "create": {
        "_index": "socteam",
        "_type": "products",
        "_id": "AVQuGPff-1Y7OIPIJaLX",
        "status": 400,
        "error": {
          "type": "mapper_parsing_exception",
          "reason": "failed to parse",
          "caused_by": {
            "type": "not_x_content_exception",
            "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
          }
        }
      }
    }
  ]
你知道这个错误是什么意思吗?我没有创建任何映射,我正在使用vanilla elasticsearch

,因此,对于文档,您必须指定索引并键入URL:

curl -XPUT 'localhost:9200/socteam/products/_bulk?pretty' --data-binary "@data.json"
它适用于PUT和POST方法。
您的data.json文件应该具有如下结构:

{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }

也许有另一种导入数据的方法,但我知道这一点。。。希望它能有所帮助……

我只有一个JSON文件,这是否意味着我必须将其分解?您需要使用POST进行
\u bulk
调用。您可以显示您正在使用的“完全卷曲”命令吗?您没有显示
-d
--data binary
参数。