Returning Raw Json in ElasticSearch NEST query

Viewed 9678

I'm doing a small research about a client for elastic search in .net and I found that NEST is one of the most supported solutions for this matter.

I was looking at Nest's docummentation and I couldn´t find a way to output a raw json from a query and avoid the serialization into an object, because I'm using angularJs in the front end I don´t want to overload the process of sending the information to the client with some unnecessary steps.

......and also I'd like to know how can I overrdide the serialization process?

I found that NEST uses Json.NET which I would like to change for the servicestack json serielizer.

thanks!

2 Answers

Use RequestResponseSerializer instead of Serializer.

var searchDescriptor = ...;
...
byte[] b = new byte[60000];
using (MemoryStream ms = new MemoryStream(b))
{
    this._client.RequestResponseSerializer.Serialize(searchDescriptor , ms);
}
var rawJson = System.Text.Encoding.Default.GetString(b);
Related