# NullPointerException when settings "es.read.field.as.array.include" options

**URL:** <https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [October 17, 2016, 8:41pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223 "2016-10-17T20:41:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [October 17, 2016, 8:41pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/1 "2016-10-17T20:41:48Z")

</div>

With Spark + ES, when I set:

> conf.set("es.read.field.as.array.include", "api\_search\_ads\_print\_data.ads");

I got the following exception:

> java.lang.NullPointerException  
> at java.lang.String.startsWith(String.java:1405)  
> at java.lang.String.startsWith(String.java:1434)  
> at org.elasticsearch.hadoop.serialization.field.FieldFilter.filter(FieldFilter.java:105)  
> at org.elasticsearch.hadoop.serialization.field.FieldFilter.filter(FieldFilter.java:132)  
> at org.elasticsearch.hadoop.serialization.builder.JdkValueReader.addToArray(JdkValueReader.java:121)

Is it clear enough or do you need more details?

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [October 17, 2016, 8:44pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/2 "2016-10-17T20:44:02Z")

</div>

> [@ebuildy](#):
>
> Is it clear enough or do you need more details?

Adding the version of the connector you are working with and the versions of the integrating technologies (ES, Spark, Hadoop, etc...) helps a great deal in troubleshooting these problems.

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [October 17, 2016, 8:55pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/3 "2016-10-17T20:55:04Z")

</div>

It's also normally helpful to include a small number of test records/mappings that can allow us to reproduce this faster.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [October 17, 2016, 9:01pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/4 "2016-10-17T21:01:35Z")

</div>

I am using:

- Spark 1.6.2
- elasticsearch 2.4
- elasticsearch-hadoop: 2.4

I will try to setup a small sample tomorrow.

Thanks,

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [November 2, 2016, 12:36pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/5 "2016-11-02T12:36:32Z")

</div>

Hello, quite easy to reproduce, a single document:

```
"a": {
                  "b": [
                     {
                        "c": "hello"
                     }
                  ]
               }

```

Settings conf.set("es.read.field.as.array.include", "a.b"); causes the NullPointerException. (I don't see this error when I use DataFrame, only RDD).

Actually, at [https://github.com/elastic/elasticsearch-hadoop/blob/2.4/mr/src/main/java/org/elasticsearch/hadoop/serialization/builder/JdkValueReader.java#L121](https://github.com/elastic/elasticsearch-hadoop/blob/2.4/mr/src/main/java/org/elasticsearch/hadoop/serialization/builder/JdkValueReader.java#L121) currentFieldName is null.

---

<div class="post-metadata">

**Author:** ![dustinschultz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dustinschultz/32/15323_2.png) [@dustinschultz](https://discuss.elastic.co/u/dustinschultz)\
**Post date:** [February 7, 2017, 10:42pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/6 "2017-02-07T22:42:29Z")

</div>

@ebuildy were you able to resolve this? I am seeing the exact same error while trying to do an ETL from one index to another.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [February 24, 2017, 12:06pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/7 "2017-02-24T12:06:30Z")

</div>

Hello,

Nop, there are plenty issues with array (latest I found =\> [Bug when reading if a field has no mapping (empty array by ex.)](https://discuss.elastic.co/t/bug-when-reading-if-a-field-has-no-mapping-empty-array-by-ex/76393) drive me crazy ^^).

So, I removed array for flat structure, no problem like that.

(having fields like toto\_1:, toto\_2: , toto\_3 instead of toto: [])

---

<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, 1:22pm UTC](https://discuss.elastic.co/t/nullpointerexception-when-settings-es-read-field-as-array-include-options/63223/8 "2017-07-06T13:22:29Z")

</div>


