# How to use Source in ElasticSearch Net

**URL:** <https://discuss.elastic.co/t/how-to-use-source-in-elasticsearch-net/366585>\
**Category:** Elasticsearch\
**Created:** [September 15, 2024, 10:55am UTC](https://discuss.elastic.co/t/how-to-use-source-in-elasticsearch-net/366585 "2024-09-15T10:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alikleitcr7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alikleitcr7/32/136346_2.png) [@alikleitcr7](https://discuss.elastic.co/u/alikleitcr7)\
**Post date:** [September 15, 2024, 10:55am UTC](https://discuss.elastic.co/t/how-to-use-source-in-elasticsearch-net/366585/1 "2024-09-15T10:55:40Z")

</div>

How can I project fields in the Elasticsearch Net 8?

I tried:

```cs
SourceFilter filter = new SourceFilter();

filter.Includes = new List<Field>() .. hm not the way

SourceConfig sourceConfig = new SourceConfig(filter);

SearchResponse<PostDocument> searchResponse = await client.SearchAsync<PostDocument>(s => s
.Index(index_name)
.From(page)
.Size(countPerPage)
.Source(sourceConfig)
.Query(..)

```

Try 2

```cs
.Source(null).Fields(
 fs => fs.Field(f => f.Id),
 fs => fs.Field(f => f.PostId),
 fs => fs.Field(f => f.Title))

```

I also saw `SourceIncludes` which takes in `Fields` but its not an expression same as the chain `Fields`

Any help? docs is still very limited

---

<div class="post-metadata">

**Author:** ![alikleitcr7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alikleitcr7/32/136346_2.png) [@alikleitcr7](https://discuss.elastic.co/u/alikleitcr7)\
**Post date:** [June 7, 2025, 11:40am UTC](https://discuss.elastic.co/t/how-to-use-source-in-elasticsearch-net/366585/2 "2025-06-07T11:40:38Z")

</div>

Dicussion mentioned [here](https://github.com/elastic/elasticsearch-net/issues/8400#issuecomment-2952371232) with possible answer

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [June 7, 2025, 5:05pm UTC](https://discuss.elastic.co/t/how-to-use-source-in-elasticsearch-net/366585/3 "2025-06-07T17:05:44Z")

</div>

Infer.Fields(x =\> x.SomeField1, x =\> x.SomeField2)

Is indeed the correct syntax to use in this case.
