Monday, 15 April 2013

asp.net - Convert NEST (Elasticsearch) Search Results to DataSet - C# -


I am using knits to find my resilience search pointer:

  Var result = client Search & lt; My Object & gt; (S => (0). Size (10) // question here);  

This works and returns a Nest.SearchResponse object. Results The format given by hit.ToList () list & lt; Nest. IHit & lt; MyObject & gt; & Gt; () .

How do I change the results returned to the dataset (or datatable)?

Any help is appreciated.

You need a loop on your results

  DataTable dt = New DataTable (); Dt.Columns.Add ("field 1", typef (string)); Dt.Columns.Add ("field2", typef (string)); ... foreach (result in IHit & lt; Jobx; x. Result as. Hit) {dt.Rows.Add (x.Fields.FieldValuesDictionary ["Prop1"] as Xera, x.Fields.FieldValuesDictionary ["Prop2 "] As JArray ...);  
  • as well as

    >

    Document with MapataData

    When you search with Nest 0.12, you will withdraw a query response with two methods of loop on your results. . The document is an IEnumerable and. DocsWithMetaData and IEnumerable> may be easy to use one of them depending on your needs.

    Starting with Nest 1.0. DocsWithMetaData now only Is called.


    No comments:

    Post a Comment