1

I am trying to import shakespeare.json as per elastic search tutorial.

[Environment]

  1. Elastic Search 2.1
  2. Sense -Extension for Chrome

[Background]

When I paste curl -XPUT localhost:9200/_bulk --data-binary @shakespeare.json on the sense tab(the extensions opens a new tab with 2 windows) It's converted to PUT /_bulk and the output is

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

[My Findings]

  1. I have downloaded shakespeare.json locally, but I think Sense is not able to locate the path where the file resides(May be, I have the file at incorrect location)
  2. I also tried finding the current directory for Sense, but I am not sure where would I find the index.html for chrome-extension in windows for this plug-in.
  3. Whatever documentation I found, is Linux specific.

Any inputs appreciated.

Ronak Agrawal
  • 1,006
  • 1
  • 19
  • 48

2 Answers2

5

You should not do this in Sense, but simply from the command line

curl -XPUT localhost:9200/_bulk --data-binary @shakespeare.json

Make sure to point to the correct path of the shakespeare.json file if it is not located in the directory you're in.

curl -XPUT localhost:9200/_bulk --data-binary @/path/to/shakespeare.json

UPDATE

If you run on Windows and you don't have the cURL command present, you can download cURL at https://curl.haxx.se/download.html

Val
  • 207,596
  • 13
  • 358
  • 360
  • No worries, glad to help! – Val Jan 08 '16 at 09:28
  • why am I getting Exception: STATUS_STACK_OVERFLOW at rip=001801D72B6 when trying to curl -XPUT? – user829174 Jan 09 '16 at 20:08
  • @user829174 your `shakespeare.json` file might be too big, you might need to split it in two or three (or more). Give it a try. – Val Jan 12 '16 at 04:26
  • shakespear.json contains index object for wach data entry. Is index object mandatory ? I am trying to export my json file without index object and it is throwing same error. – Harshit Dec 03 '16 at 01:59
  • @Harshit I suggest you create a new question for your specific problem since this one was about import, not export. – Val Dec 03 '16 at 04:46
  • Sorry, my bad. I mean import. I am trying to import json file which do not have index object. – Harshit Dec 03 '16 at 06:51
  • Nevermind. I found my answer at http://stackoverflow.com/questions/32863112/elasticsearch-bulk-index-api-via-rest-endpoint Thanks @Val – Harshit Dec 03 '16 at 07:04
0

In Latest ElasticSearch 6, to populate the sharespeare_6.0.json, the following is the curl command

curl -H Content-Type:application/x-ndjson -XPUT localhost:9200/shakespeare/doc/_bulk --data-binary @shakespeare_6.0.json

Ankireddy Polu
  • 1,824
  • 16
  • 16