Skip to content

Question: ElasticsearchClient.Bulk with object array containing Deserialized JSON #1464

@JamieDixon

Description

@JamieDixon

Hi there.

I'm trying to use the bulk API and am hitting a problem with the way dynamic entries are being handled. It looks like it's a serialization issue.

Given the following:

var bulkEntries = new List<object>();
var bulkEntry = new {index = new { _index = "ourIndex", _type = "ourType", _id = "ourId"}}
bulkEntries.Add(bulkEntry);

Here's two examples, one that works as expected and one that doesn't:

Working

bulkEntries.Add(new { id = 1 });

Not working

var doc = JsonConvert.DeserializeObject<dynamic>(document);
doc.someprop = "some value";

bulkEntries.Add(doc);

In the second example, when we call:

var bulkResponse = client.Bulk(bulkEntries);

The response looks like:

Request: {"index":{"_index":"ourIndex","_type":"ourType","_id":"ourId"}}
[[[]],[[]]]

I'm probably just doing something wrong. Any pointers would be appreciated.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions