0

I am trying to insert/update data with the javascript elasticsearch client, but I am getting the error:

  {
    "error": {
      "root_cause": [
        {
          "type": "illegal_argument_exception",
          "reason": "Malformed action/metadata line [1], expected a simple value for field [_data] but found [START_OBJECT]"
        }
      ],
      "type": "illegal_argument_exception",
      "reason": "Malformed action/metadata line [1], expected a simple value for field [_data] but found [START_OBJECT]"
    },
    "status": 400
  }

This is the data that is being sent

esclient.bulk({
    body: [
        {
            "index":
            {
                "_index":"myindex",
                "_type":"movie",
                "_id":"1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
                "_data": 
                {
                    "title":"Title 2",
                    "description":"This should be updated with this new data.",
                    "score":1,
                    "suggest_title":"Title 2",
                    "img":"http://url.to.image/img.jpeg",
                    "genres":["Comedy"],
                    "release":"2015-01-07T23:00:00.000Z",
                    "language":"EN",
                    "provider":
                    {
                        "id":"InstaFilmFlixify",
                        "url":"http://www.InstaFilmFlixify.com/play?id=238412"
                    }
                }
            }
        }
    ]
})

It appears as this code generates the following request to ES:

 -> POST http://docker.me:9200/_bulk
  {
    "index": {
      "_index": "myindex",
      "_type": "movie",
      "_id": "1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
      "_data": {
        "title": "Title 2",
        "description": "This should be updated with this new.",
        "score": 1,
        "suggest_title": "Title 2",
        "img": "http://url.to.image/img.jpeg",
        "genres": [
          "Comedy"
        ],
        "release": "2015-01-07T23:00:00.000Z",
        "language": "EN",
        "provider": {
          "id": "InstaFilmFlixify",
          "url": "http://www.InstaFilmFlixify.com/play?id=238412"
        }
      }
    }
  }

What am I doing wrong? What is happening? Can this possibly be a bug in ES / the ES adapter.


Elasticsearch version 2.1

1
  • What does your mapping look like? Commented Dec 8, 2015 at 16:24

1 Answer 1

1

I haven't seen the "_data" parameter before. Where did you get the idea to use that?

Take a look at the docs for the js client.

Anyway, this should work for you:

esclient.bulk({
    body: [
        {
            "index":
            {
                "_index":"myindex",
                "_type":"movie",
                "_id":"1IEAEHNOIORANIT4SEOASNIE3HAETN2E...",
            }
        },
        {
            "title":"Title 2",
            "description":"This should be updated with this new data.",
            "score":1,
            "suggest_title":"Title 2",
            "img":"http://url.to.image/img.jpeg",
            "genres":["Comedy"],
            "release":"2015-01-07T23:00:00.000Z",
            "language":"EN",
            "provider":
            {
                "id":"InstaFilmFlixify",
                "url":"http://www.InstaFilmFlixify.com/play?id=238412"
            }
        }
    ]
})
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, you are right. This "_data" thing is something I have found in some old docs or something. I was unsuccessful at finding the source, but it may have been a blog post somewhere. I found that I had copied over some old temporary code in stead of the correctly formatted one.

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.