# Can't save a List\<int?\> on Elasticsearch 5.6.5

**URL:** <https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267>\
**Category:** Elasticsearch\
**Created:** [July 18, 2019, 7:12pm UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267 "2019-07-18T19:12:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CSharpBender](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/csharpbender/32/50377_2.png) [@CSharpBender](https://discuss.elastic.co/u/CSharpBender)\
**Post date:** [July 18, 2019, 7:12pm UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267/1 "2019-07-18T19:12:17Z")

</div>

I've been playing with NEST 5.6.5 to see how it's treating the Nullable types in Elasticsearch.

While serializing a NEST request I've noticed that for int? it's just a number and when it's null the value is not sent.  
When I use a List\<int?\> the mapping changes to an object with the properties: hasValue and value.  
The problem is that this time the values are sent as integers or null, instead of {hasValue:true, value:123} or {hasValue:false} and I'm getting a serialization error.

What should I do to be able to save a List\<int?\> ?  
From the mapping it's obvious that this weird scenario should be supported so why it's not working?

---

<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:** [July 19, 2019, 8:56am UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267/2 "2019-07-19T08:56:22Z")

</div>

Take a look at the [mapping docs](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/mapping.html) as I think it'll answer your questions. You likely want to use automapping to map the `List<int?>` as the integer data type.

---

<div class="post-metadata">

**Author:** ![CSharpBender](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/csharpbender/32/50377_2.png) [@CSharpBender](https://discuss.elastic.co/u/CSharpBender)\
**Post date:** [July 19, 2019, 9:22am UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267/3 "2019-07-19T09:22:58Z")

</div>

I used automapping.

---

<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:** [July 19, 2019, 10:10am UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267/4 "2019-07-19T10:10:58Z")

</div>

Can you provide a reproducible example please? Also, what version of Elasticsearch are you running against?

---

<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:** [August 16, 2019, 10:11am UTC](https://discuss.elastic.co/t/cant-save-a-list-int-on-elasticsearch-5-6-5/191267/5 "2019-08-16T10:11:03Z")

</div>

Closed on August 16, 2019, 10:11am UTC

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