title: How do you get search results returned in nest 1.x mapped to an object?
body: <p>I am creating a query in nest</p>
  
  <pre><code>var searchResult = ( (ElasticClient)_Db ).Search&lt;PackageRecord, PackageRecordSearchHit&gt; ( s =&gt; s
      .Index ( Db_deals_IndexName )
      .Type ( Db_Package_TypeName )
      .From ( request.Page * _DefaultPageSize )
      .Size ( _DefaultPageSize )
  
      .Query ( q =&gt; q
          .QueryString ( qs =&gt;qs
              .OnFields (  f =&gt;f.TenantId )
              .Query ( user.Tenant.Id.ToString () ) )
      &amp;&amp;
       q.Nested ( n =&gt; n
          .Path ( f =&gt; f.List_BorrowerSet[ 0 ] )
          .Query ( qm =&gt; qm.QueryString ( qs =&gt; qs
              .OnFields (
       f =&gt; f.List_BorrowerSet.First ().PrimaryBorrower.ContactDetails.Name_First,
       f =&gt; f.List_BorrowerSet.First ().PrimaryBorrower.ContactDetails.Name_Last
       )
              .Query ( request.SearchValue ) )
                 &amp;&amp; qm
              .Term (
              f =&gt; f.List_BorrowerSet.First ().IsPrimary, true )
              ) )
              ||
              q.QueryString ( qs =&gt;
                  qs.OnFields ( f =&gt;
                      f.Collateral.SubjectProperty.Address.AddressLineText )
                      .Query ( request.SearchValue ) )
              ||
              q.QueryString ( qs =&gt;
                  qs.OnFields ( f =&gt;
                      f.DisplayName )
                      .Query ( request.SearchValue ) )
  
      )
  
      .Fields (
          f =&gt; f.Id,
          f =&gt; f.DisplayName,
          f =&gt; f.List_BorrowerSet[ 0 ].IsPrimary,
          f =&gt; f.List_BorrowerSet[ 0 ].PrimaryBorrower.ContactDetails.Name_First,
          f =&gt; f.List_BorrowerSet[ 0 ].PrimaryBorrower.ContactDetails.Name_Last,
          f =&gt; f.Collateral.SubjectProperty.Address.AddressLineText
      )
  
      .SortAscending ( f =&gt; f.List_BorrowerSet.First ().PrimaryBorrower.ContactDetails.Name_Last )
      .SortAscending ( f =&gt; f.List_BorrowerSet.First ().PrimaryBorrower.ContactDetails.Name_First )
  
      );
  </code></pre>
  
  <p>This returns 6 hits but no documents.  I have looked at the hit results but I can't figure out how to deal with a missing /null field when using</p>
  
  <pre><code>foreach ( var hit in searchResult.Hit)
  {
      response.Hits.Add ( new PackageSearchResultItem ()
      {
      //    Id = hit.Fields.FieldValues&lt;List&lt;Guid&gt;&gt; ( "id" ).FirstOrDefault(),
      //    DisplayName = hit.Fields.FieldValues&lt;string[]&gt; ( "displayName" ).FirstOrDefault(),
      //    BorrowerFirstName = hit.Fields.FieldValues&lt;string[]&gt; ( "list_BorrowerSet.primaryBorrower.contactDetails.name_First" ).FirstOrDefault (),  
      //    BorrowerLastName = hit.Fields.FieldValues&lt;string[]&gt; ( "list_BorrowerSet.primaryBorrower.contactDetails.name_Last" ).FirstOrDefault (),
      //    PropertyAddress = hit.Fields.FieldValues&lt;string[]&gt; ( "collateral.subjectProperty.address.AddressLineText" ).FirstOrDefault ()
      } );
  }
  </code></pre>
  
  <p>What is the proper way to get my search results mapped to <code>PackageRecordSearchHit</code> objects?</p>