Return Raw Json to ElasticSearch NEST request

I am doing a little research on the client to search for elasticity in .net, and I have found that NEST is one of the most supported solutions on this.

I looked at the Docummentation Nest and I could not find a way to output raw json from the request and avoid serializing to the object, because I use angularJs in the interface. I do not want to overload the process of sending information to the client with some unnecessary steps.

...... and also I would like to know how can I override the serialization process?

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

thanks!

+7
servicestack elasticsearch nest
source share
2 answers

Hi Pedro, you can do it with NEST

var searchDescriptor = new SearchDescriptor<ElasticSearchProject>() .Query(q=>q.MatchAll()); var request = this._client.Serializer.Serialize(searchDescriptor); ConnectionStatus result = this._client.Raw.SearchPost(request); Assert.NotNull(result); Assert.True(result.Success); Assert.IsNotEmpty(result.Result); 

This allows you to strictly enter your queries, but return the .Result string, which is the raw response from elasticsearch as a string to your

request can be an object or a string, so if you're ok with the internal json serializer, just go through the searchDescriptor directly

+9
source share

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); 
0
source share

All Articles