通过python将json数据转储到elasticsearch中

2024-05-29 10:24:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将一些从csv文件解析的json数据转储到elasticsearch中。我已经检查了数据和格式是否正确。但由于某些原因,我得到了下面的错误。在

{
  "error" : {
    "root_cause" : [ {
      "type" : "parse_exception",
      "reason" : "Failed to derive xcontent"
    } ],
    "type" : "parse_exception",
    "reason" : "Failed to derive xcontent"
  },
  "status" : 400
}

这是我使用的命令。我不知道为什么它不起作用

^{pr2}$

编辑:这是我的json数据的一部分。我知道错误很可能来自于此,但我不知道是什么。我已经通读了elasticsearch上的Bulk_API。在

{"index": {"_index": "jobs", "_id": 119556, "_type": "2014_jobs"}}
{"job category": "Logistics / Supply Chain|Purchasing / Merchandising|Human resource consultancy services|Full Time|Executive|Manager|Middle Management|", "closing date": "28-Dec-14", "salary": "Not published", "posting date": "28-Nov-14", "working hours": "-", "company": "", "contact": "+65 66454545 / ctay sg. drakeintl. com", "description": "", "title": "Logistics Category Manager", "job level": "Executive|Manager|Middle Management", "shift pattern": "Day Shift", "job id": "JOB-2014-0119556", "industry": "Human resource consultancy services", "employment type": "Full Time", "min years of experience": "8", "skills": "", "timestamp": "1.41973E+12", "address": "1 RAFFLES PLACE| 20-01 ONE RAFFLES PLACE||Singapore 048616|"}
{"index": {"_index": "jobs", "_id": 119700, "_type": "2014_jobs"}}
{"job category": "F B|Hospitality|Logistics / Supply Chain|Purchasing / Merchandising|Hotels with restaurant|Full Time|Fresh/entry level|Non-executive|", "closing date": "28-Dec-14", "salary": "Not published", "posting date": "28-Nov-14", "working hours": "44 hours a week", "company": "DAISHO DEVELOPMENT SINGAPORE PTE LTD", "contact": "Not available", "description": "", "title": "Culinary Logistic Agent", "job level": "Fresh/entry level|Non-executive", "shift pattern": "No Shift", "job id": "JOB-2014-0119700", "industry": "Hotels with restaurant", "employment type": "Full Time", "min years of experience": "1", "skills": "", "timestamp": "1.41973E+12", "address": "12 MARINA VIEW| 35-00 ASIA SQUARE TOWER 2||Singapore 018961|"}
{"index": {"_index": "jobs", "_id": 118701, "_type": "2014_jobs"}}
{"job category": "Architecture / Interior Design|Architectural services|Permanent|", "closing date": "30-Dec-14", "salary": "Not published", "posting date": "27-Nov-14", "working hours": "8am - 6pm", "company": "LOOK ARCHITECTS PTE. LTD. ", "contact": "jasmin lookarchitects. com", "description": "", "title": "Resident Technical Officer (RTO)", "job level": "-", "shift pattern": "No Shift", "job id": "JOB-2014-0118701", "industry": "Architectural services", "employment type": "Permanent", "min years of experience": "5", "skills": "", "timestamp": "1.41973E+12", "address": "18 BOON LAY WAY| 09-135 TRADEHUB 21||Singapore 609966|"}

Tags: 数据iddateindextimetypeservicejobs
2条回答

您得到的错误与另一个问题相同,问题是没有提供数据文件的完整路径:link to the answer to that question。在

在这种情况下,从:

curl -XPUT 'http://192.168.99.100:9200/_bulk?pretty'  data-binary "@data.json"

收件人:

^{pr2}$

应该能解决问题。在

尝试用更新替换bulk

curl -XPUT 'http://192.168.99.100:9200/_update?pretty'  data-binary "@data.json"

参考号:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

相关问题 更多 >

    热门问题