# Int field is updated to 0 even though field already was set to !0 and field null is defined 0?

**URL:** <https://discuss.elastic.co/t/int-field-is-updated-to-0-even-though-field-already-was-set-to-0-and-field-null-is-defined-0/29709>\
**Category:** Elasticsearch\
**Created:** [September 21, 2015, 3:21pm UTC](https://discuss.elastic.co/t/int-field-is-updated-to-0-even-though-field-already-was-set-to-0-and-field-null-is-defined-0/29709 "2015-09-21T15:21:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drortrie](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@drortrie](https://discuss.elastic.co/u/drortrie)\
**Post date:** [September 21, 2015, 3:21pm UTC](https://discuss.elastic.co/t/int-field-is-updated-to-0-even-though-field-already-was-set-to-0-and-field-null-is-defined-0/29709/1 "2015-09-21T15:21:27Z")

</div>

Hi all,

I'm using elastic 1.72 on Windows,  
writing to the elastic with C# NEST client.

I defined a type "TcpPacket" with int field "SrcPort" with "null\_value" to be 0.  
The code inserts TcpPacket documents and updates those documents with extra concluded data.

I have a conceptual problem with updating the "SrcPort" int field, in example:  
a. TcpPacket document is inserted with SrcPort=X (not 0).

b. Later, an update event occurs with new C# TcpPacket object where the SrcPort=0 (because I can't conclude the SrcPort with the new data). The updating algorithm:

1. Find the original document elastic\_id (the TcpPacket document still with SrcPort=X)

2. Update the document with the elastic\_id  
the code:  
_\_elasticClient.Update(descriptor =\> descriptor.Type(pocoObject.GetType()).Id(elasticID).Doc(pocoObject))_

3. Finish update process (Now the TcpPacket document had scrPort=0)

For other "null" values, where the field is string type for example, the original value is kept well.

Now, I know that dealing with Int is different than other types, but is there any configuration I can make so when the field updated value is 0, the original value will not be updated to 0 and stays the original value?

Thanks

---

<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:** [July 5, 2017, 11:49pm UTC](https://discuss.elastic.co/t/int-field-is-updated-to-0-even-though-field-already-was-set-to-0-and-field-null-is-defined-0/29709/2 "2017-07-05T23:49:02Z")

</div>

Closed on July 5, 2017, 11:49pm UTC


