# Elasticsearch NEST client \[search\] requests with source filtering are not working as expected

**URL:** <https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412>\
**Category:** Elasticsearch\
**Created:** [February 5, 2018, 9:00am UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412 "2018-02-05T09:00:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![manwa](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@manwa](https://discuss.elastic.co/u/manwa)\
**Post date:** [February 5, 2018, 9:00am UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/1 "2018-02-05T09:00:47Z")

</div>

Hello ,  
I'm currently using elasticsearch NEST client v 6.0.0 with ES v6.1.2.  
When i use NEST search request with source filtering to include the specified fields only in the returned documents, the source for each document will be empty!

Here is the debug info object i've got :

```
Valid NEST response built from a successful low level call on POST: /indexName/typeName/_search?
typed_keys=true
# Audit trail of this API call:
 - [1] HealthyResponse: Node: http://ESipAddress:9200/ Took: 00:00:00.0312084
# Request:
{"from":0,"size":50,"_source":{"includes":["ID","Name","Description","Category"]}}
# Response:
{"took":13,"timed_out":false,"_shards":{"total":2,"successful":2,"skipped":0,"failed":0},"hits":
{"total":154919,"max_score":1.0,"hits":
[{"_index":"indexName","_type":"typeName","_id":"45484","_score":1.0,"_source":{}} }}

```

And I'v noticed something, the following search request will return zero hits (its a valid request) when it was done via elastic NEST client but when i try to execute it from elastic Head on GET not POST the results are returned as expected . Here is the debug info of the request made:

```
Valid NEST response built from a successful low level call on POST: /content/_search?typed_keys=true
# Audit trail of this API call:
- [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.0937397
# Request:
{"from":0,"size":50,"_source":true,"query":{"bool":{"must":[{"terms":{"ClassID":
["5","419","422","442","80","85","434","436","439","87","76"]}}]}}}
# Response:
{"took":16,"timed_out":false,"_shards":{"total":6,"successful":6,"skipped":0,"failed":0},"hits":
{"total":0,"max_score":null,"hits":[]}} 

```

Any thing may help ?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [February 5, 2018, 10:33am UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/2 "2018-02-05T10:33:21Z")

</div>

What does the mapping look like for `indexName`?

---

<div class="post-metadata">

**Author:** ![manwa](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@manwa](https://discuss.elastic.co/u/manwa)\
**Post date:** [February 5, 2018, 10:50am UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/3 "2018-02-05T10:50:24Z")

</div>

{  
"state": "open",  
"settings": {  
"index": {  
"refresh\_interval": "5s",  
"number\_of\_shards": "2",  
"provided\_name": "indexName",  
"creation\_date": "1517711010125",  
"analysis": {  
"analyzer": {  
"case\_insensitive\_sort": {  
"filter": [  
"lowercase"  
],  
"type": "custom",  
"tokenizer": "keyword"  
}  
}  
},  
"number\_of\_replicas": "1",  
"uuid": "yMa2tL5qQZmCqaYeEfAePg",  
"version": {  
"created": "6010299"  
}  
}  
},  
"mappings": {  
"typeName": {  
"dynamic": "strict",  
"\_all": {  
"enabled": false  
},  
"properties": {  
"container": {  
"type": "keyword"  
},  
"iD": {  
"type": "keyword"  
},  
"name": {  
"analyzer": "case\_insensitive\_sort",  
"type": "text"  
},  
"description": {  
"analyzer": "case\_insensitive\_sort",  
"type": "text"  
},  
"category": {  
"type": "keyword"  
}  
"location": {  
"type": "keyword"  
},  
"sourceLocation": {  
"index": false,  
"type": "text"  
},  
"sourceName": {  
"analyzer": "case\_insensitive\_sort",  
"type": "text"  
}  
}  
}  
},  
"aliases": [  
"content"  
],  
"primary\_terms": {  
"0": 1,  
"1": 1  
},  
"in\_sync\_allocations": {  
"0": [  
"VUdRpr2DQqSQwsXdkLCDXA"  
,  
"UMvsjttLQfyi7-UGOGZNAg"  
],  
"1": [  
"pYsDWyP4Tj-42ivUi7xdfQ"  
,  
"Vh08AEZTT7uPSjjUqlskKQ"  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [February 5, 2018, 12:10pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/4 "2018-02-05T12:10:43Z")

</div>

The names of the fields in the source includes need to match the names in the mapping.

If you look at the request in question, the field names are Pascal cased e.g. `Name`, but you can see in the mapping that field names are Camel cased e.g. `name`

---

<div class="post-metadata">

**Author:** ![manwa](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@manwa](https://discuss.elastic.co/u/manwa)\
**Post date:** [February 5, 2018, 12:27pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/5 "2018-02-05T12:27:55Z")

</div>

Yeah 😳 I've modified that mistake and its working fine now Thank you .

---

<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:** [March 5, 2018, 12:28pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-client-search-requests-with-source-filtering-are-not-working-as-expected/118412/6 "2018-03-05T12:28:03Z")

</div>

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