2

I am trying to import some json data into my elasticsearch instance and getting the following error:

{
  "error" : "JsonParseException[Unexpected end-of-input: expected close marker for ARRAY (from [Source: [B@7110db07; line: 1, column: 0])\n at [Source: [B@7110db07; line: 1, column: 3]]",
  "status" : 500
}

I am using an Ubuntu (14.04) running on VirtualBox and this is the command I used to import the data:

url -XPOST 'localhost:9200/mydata/fields/_bulk?pretty' --data-binary @mydata.json

And here is my JSON sample:

[
  {
    "field1":"sometext",
    "field2":"O",
    "field3":"TEXT",
    "field4":"CR",
    "field5":"09:38.0",
    "field6":"09:38.0",
    "field7":"14:13.0",
    "field8":"NULL",
    "field9":"NULL",
    "field10":"0",
    "field11":"5",
    "field12":"NULL",
    "field13":"NULL",
    "field14":"4",
    "field15":"0"
  },
  {
    "field1":"othertext",
    "field2":"O",
    "field3":"TEXT",
    "field4":"CR",
    "field5":"09:38.0",
    "field6":"09:38.0",
    "field7":"14:13.0",
    "field8":"NULL",
    "field9":"NULL",
    "field10":"0",
    "field11":"5",
    "field12":"NULL",
    "field13":"NULL",
    "field14":"4",
    "field15":"0"
  },
]

Is is possible to import a JSON array using the bulk API?

3
  • 1
    Corrected json format is like so: {"index":{"_index":"mydata","_type":"data","_id":0}} {"field1":"someText","field2":"O","field3":"TEXT","field4":"CR","field5":"09:38.0","field6":"09:38.0","field7":"14:13.0","field8":"NULL","field9":"NULL","field10":"0","field11":"5","field12":"NULL","field13":"NULL","field14":"4","field15":"0"} Commented Jul 15, 2014 at 17:40
  • what about the second record? Commented Feb 3, 2016 at 18:37
  • how did you post multiple records using bulk api? i always get an error? Commented Feb 3, 2016 at 18:41

1 Answer 1

4

Your json doesnt have to contain line breaks in the bulk API, since the API uses the line break as a delimiter. From elasticsearch documentation here http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html

Because this format uses literal \n's as delimiters, please be sure that the JSON actions and sources are not pretty printed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.