Query DSL C#, function "Documents" return issue

Hello,

I'am trying to get to some data on a elastic uri.
The thing is, when I do this :

           var searchResponse = client.Search<Source>(s => s
            .Index("jam")
            .Type("jam")
            .From(0)
            .Size(1000)
            .Query(q => q
            .Match(m =>m
            .Field(f => f.Street)
            .Query("Paris")
            )
           )
           );

        var recep = searchResponse.Documents;

recep return :

  System.Collections.Generic.List'1[WpfApp1.Source]

The thing i dont understand is i actually get the correct "total" amount of hits but i just can't put in in a string or in a object.
And the recep return is the path to my hits but static, he dont take the 100 hits to put it in recep he just give the path, how can i fix it ?

searchResponse.Documents is a collection of Source documents, deserialized from the _source field of each hit in the response. The generic parameter type passed in .Search<T>(...) tells NEST what type to deserialize _source objects into.

You can use the low level client if you want to return the entire response as a string e.g. using NEST 6.x

var searchResponse = client.LowLevel.Search<StringResponse>("jam", "jam", PostData.Serializable(new SearchDescriptor<Question>()
    .From(0)
    .Size(10)
    .Query(q => q
        .Match(m => m
            .Field(f => f.Body)
            .Query("Paris")
        )
    )
));

// response from Elasticsearch as a JSON string
var jsonString = searchResponse.Body;

Take a look at the NEST documentation getting started section for more details.

Wow thank you so much, that's exactly what i was looking for :grin:

I've waste my time being completly focus on NEST high level.
Ill take a look at the documentation but i'm on it since two days..
Because i already recieve data in that kind of format so i had an error using NEST high level.

Have a nice day, thanks again

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