# Fields option using NEST

**URL:** <https://discuss.elastic.co/t/fields-option-using-nest/345954>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 27, 2023, 8:28pm UTC](https://discuss.elastic.co/t/fields-option-using-nest/345954 "2023-10-27T20:28:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xef](https://avatars.discourse-cdn.com/v4/letter/x/898d66/32.png) [@xef](https://discuss.elastic.co/u/xef)\
**Post date:** [October 27, 2023, 8:28pm UTC](https://discuss.elastic.co/t/fields-option-using-nest/345954/1 "2023-10-27T20:28:23Z")

</div>

When using the Fieds options just to get a selection of fileds using the NEST client library and setting the Source(false), the Hits object's fields property is null. How are we supposed to get access to the values returned if source is also null by setting Source(false).

Example:

> var searchResponse =  
> await ElasticSearchConfig.GetClient().SearchAsync(x =\> x.Index(indices)  
> .Size(1000)  
> .Source(sr =\> sr  
> .Includes(fi =\> fi  
> .Fields(  
> f =\> f.Id,  
> f =\> f.Name,  
> f =\> f.Age,  
> f =\> f.Address,  
> f =\> f.DateRegistered  
> )  
> )).Source(false)  
> .Query(q =\> q  
> .Bool(bq =\>  
> bq.Filter(  
> fq =\> fq.DateRange(t =\> t.Field(f =\> f.DateRegistered).LessThanOrEquals(DateTimeOffset.UtcNow.AddDays(7).ToString("o"))))  
> )));

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 24, 2023, 8:28pm UTC](https://discuss.elastic.co/t/fields-option-using-nest/345954/2 "2023-11-24T20:28:41Z")

</div>

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