# NumberFormatException issues caused by an empty string

**URL:** <https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832>\
**Category:** Elasticsearch\
**Created:** [November 10, 2011, 11:13am UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832 "2011-11-10T11:13:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_B](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@K\_B](https://discuss.elastic.co/u/K_B)\
**Post date:** [November 10, 2011, 11:13am UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/1 "2011-11-10T11:13:32Z")

</div>

Hello,

I know we had this in the past, but could please a feature be  
introduced to have a flag at numbers like integer, float, etc, so we  
can have ES make empty Strings a "null" value instead?  
Currently an empty String "" ceates a  
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
[field] exception;

I have this problem when data extracted from XML is passed to ES (done  
by ExtractValue in mysql - he can't differ if null or emptyString  
there);

Best

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [November 10, 2011, 1:29pm UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/2 "2011-11-10T13:29:04Z")

</div>

When you define a null\_value is there still this exception?

Peter.

On Nov 10, 12:13 pm, "K.B." [korbinian.ba...@googlemail.com](mailto:korbinian.ba...@googlemail.com) wrote:

> Hello,
> 
> I know we had this in the past, but could please a feature be  
> introduced to have a flag at numbers like integer, float, etc, so we  
> can have ES make empty Strings a "null" value instead?  
> Currently an empty String "" ceates a  
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> [field] exception;
> 
> I have this problem when data extracted from XML is passed to ES (done  
> by ExtractValue in mysql - he can't differ if null or emptyString  
> there);
> 
> Best

---

<div class="post-metadata">

**Author:** ![K\_B](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@K\_B](https://discuss.elastic.co/u/K_B)\
**Post date:** [November 10, 2011, 5:15pm UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/3 "2011-11-10T17:15:35Z")

</div>

Hello Peter,

sorry, but I can't follow you. What do you mean?

On 10 Nov., 14:29, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:

> When you define a null\_value is there still this exception?
> 
> Peter.
> 
> On Nov 10, 12:13 pm, "K.B." [korbinian.ba...@googlemail.com](mailto:korbinian.ba...@googlemail.com) wrote:
> 
> > Hello,
> 
> > I know we had this in the past, but could please a feature be  
> > introduced to have a flag at numbers like integer, float, etc, so we  
> > can have ES make empty Strings a "null" value instead?  
> > Currently an empty String "" ceates a  
> > org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> > [field] exception;
> 
> > I have this problem when data extracted from XML is passed to ES (done  
> > by ExtractValue in mysql - he can't differ if null or emptyString  
> > there);
> 
> > Best

---

<div class="post-metadata">

**Author:** ![K\_B](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@K\_B](https://discuss.elastic.co/u/K_B)\
**Post date:** [November 10, 2011, 10:26pm UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/4 "2011-11-10T22:26:03Z")

</div>

Ok, tested it:

if I do:

"null\_value" : ""

then it gets this error:

org.elasticsearch.index.mapper.MapperParsingException: mapping  
[app\_shop\_produkt]  
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService  
$1.execute(MetaDataCreateIndexService.java:242)  
at org.elasticsearch.cluster.service.InternalClusterService  
$2.run(InternalClusterService.java:205)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:680)  
Caused by: java.lang.NumberFormatException: For input string: ""  
at  
java.lang.NumberFormatException.forInputString(NumberFormatException.java:  
48)

So, ES complains about the wrong mapping.

On 10 Nov., 18:15, "K.B." [korbinian.ba...@googlemail.com](mailto:korbinian.ba...@googlemail.com) wrote:

> Hello Peter,
> 
> sorry, but I can't follow you. What do you mean?
> 
> On 10 Nov., 14:29, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> 
> > When you define a null\_value is there still this exception?
> 
> > Peter.
> 
> > On Nov 10, 12:13 pm, "K.B." [korbinian.ba...@googlemail.com](mailto:korbinian.ba...@googlemail.com) wrote:
> 
> > > Hello,
> 
> > > I know we had this in the past, but could please a feature be  
> > > introduced to have a flag at numbers like integer, float, etc, so we  
> > > can have ES make empty Strings a "null" value instead?  
> > > Currently an empty String "" ceates a  
> > > org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> > > [field] exception;
> 
> > > I have this problem when data extracted from XML is passed to ES (done  
> > > by ExtractValue in mysql - he can't differ if null or emptyString  
> > > there);
> 
> > > Best

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 13, 2011, 7:14am UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/5 "2011-11-13T07:14:50Z")

</div>

We can support empty strings as null values for numeric types. Open an  
issue. Btw, why not fix the transformation?

On Thu, Nov 10, 2011 at 1:13 PM, K.B. [korbinian.bachl@googlemail.com](mailto:korbinian.bachl@googlemail.com)wrote:

> Hello,
> 
> I know we had this in the past, but could please a feature be  
> introduced to have a flag at numbers like integer, float, etc, so we  
> can have ES make empty Strings a "null" value instead?  
> Currently an empty String "" ceates a  
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> [field] exception;
> 
> I have this problem when data extracted from XML is passed to ES (done  
> by ExtractValue in mysql - he can't differ if null or emptyString  
> there);
> 
> Best

---

<div class="post-metadata">

**Author:** ![K\_B](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@K\_B](https://discuss.elastic.co/u/K_B)\
**Post date:** [November 16, 2011, 10:57am UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/6 "2011-11-16T10:57:36Z")

</div>

> Btw, why not fix the transformation?

Hi Shay, thanks for the hint. I'm doing this already, but this means  
another iteration through the data costing CPU + time;  
Currently we grab an SQL result from MYSQL that already is in a map  
form and pass it to ES via Java API. Problem here is that mysql can't  
easily understand that some of the extracted XML values are not String  
and instead makes them all to String. This then leads to trouble for  
sorting order... so we define for ES some fields as numeric, but then  
are buggered with this empty "" and null problem;

Best

On 13 Nov., 08:14, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> We can support empty strings as null values for numeric types. Open an  
> issue. Btw, why not fix the transformation?
> 
> On Thu, Nov 10, 2011 at 1:13 PM, K.B. [korbinian.ba...@googlemail.com](mailto:korbinian.ba...@googlemail.com)wrote:
> 
> > Hello,
> 
> > I know we had this in the past, but could please a feature be  
> > introduced to have a flag at numbers like integer, float, etc, so we  
> > can have ES make empty Strings a "null" value instead?  
> > Currently an empty String "" ceates a  
> > org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> > [field] exception;
> 
> > I have this problem when data extracted from XML is passed to ES (done  
> > by ExtractValue in mysql - he can't differ if null or emptyString  
> > there);
> 
> > Best

---

<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 6, 2017, 3:48am UTC](https://discuss.elastic.co/t/numberformatexception-issues-caused-by-an-empty-string/5832/7 "2017-07-06T03:48:27Z")

</div>


