Unable to index a json string (array of json objects) to elastic search

I have an array of objects in the form of a single json string something like

"[{"id": 1, "name":"test"}, {"id": 2, "name":"test2"}]"

I want to be able to bulk index this json string directly to elastic search without having to deserialize it into a model since the usual client.IndexMany() takes in an IEnumerable as parameter.

var response = client.Bulk<StringResponse>("indexname", jsonString);

I am getting a 400 response on trying to do the above.

You can't do that.

You must index individual documents.

Note that the Bulk API is expecting aother format with header and body. See

Assume i am successfully using the above format , can i still send a json string to the Bulk api or the IndexMany() method ?? Did you mean passing a json string works only for a single document at a time ?

Or do i have to first convert the json string (right format) i have to an IEnumerable<object> and then pass it something like this -

IEnumerable<object> objsToIndex = something;
var response= client.Bulk("indexname", PostData.MultiJson(objsToIndex));

You need to convert it to something elasticsearch can understand. I don't know the method you mentioned.

Can you please share an example of what conversion you are referring to.

also, are you aware if can we use Elasticsearch.Net or NEST to interact with aws managed elastic search instance ?

That might work but we can't support you here as it's not official.

BTW did you look at Cloud by Elastic, also available if needed from AWS Marketplace ?

Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, Maps UI, Alerting and built-in solutions named Observability, Security, Enterprise Search and what is coming next :slight_smile: ...

Not an array but something which is described in the bulk api link I shared.

I don't know what are the other options for .net though.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.