Venkat
Venkat

Reputation: 311

{"error":"MapperParsingException[Malformed content, must start with an object]","status":400}

I tried inserting my JSON file using the command

curl -XPOST 'http://localhost:9200/test/sec5/1' -d @quality.json

[
  {
    "Provider ID":"###",
    "Hospital Name":"## #### ###",
    "Address":"## ## ## ## ",
    "City":"###",
    "State":"IL",
    "ZIP Code":##,
    "County Name":"$$$$",
    "Phone Number":###,
    "Condition":"## ## ###",
    "Measure ID":"AMI_10",
    "Measure Name":"## ## ##",
    "Score":"98",
    "state_score":99,
    "nat_score":98,
    "percent_s_score":"98.989898989899",
    "percent_n_score":"100",
    "Sample":"101",
    "patient errors":"2.02",
    "Footnote":"",
    "Measure Start Date":"4/1/2013",
    "Measure End Date":"12/31/2013"
  },
  {
      "Provider ID":"###",
    "Hospital Name":"## #### ###",
    .................

    "Measure Start Date":"4/1/2013",
    "Measure End Date":"12/31/2013"
  },

...........
.........

]

what is wrong with my JSON format? Thank you in advance.

Upvotes: 3

Views: 3066

Answers (1)

Jakub Matczak
Jakub Matczak

Reputation: 15656

Error message clearly says what's going on here.

{“error”:“MapperParsingException[Malformed content, must start with an object]”,“status”:400}

That means that you have to wrap whole content with {...} Also you can't do something like:

{ [...] }

Because it's not a valid JSON doc. JSON object needs to be in format of name-value pairs like:

{ "data": [...] }

But then it will be treated as a single doc to index and I guess that's not what you expect it to be. You're trying to index multiple documents at once.

Basically you can't do that this way. For multiple "actions" in one query you should use the Bulk API. It's a bit more complex that a simple query so I won't explain it here. Just read the docs.

Upvotes: 4

Related Questions