# Null pointer exception for finding an integer in an array

**URL:** <https://discuss.elastic.co/t/null-pointer-exception-for-finding-an-integer-in-an-array/64663>\
**Category:** Elasticsearch\
**Created:** [November 2, 2016, 4:41am UTC](https://discuss.elastic.co/t/null-pointer-exception-for-finding-an-integer-in-an-array/64663 "2016-11-02T04:41:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pungent](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@pungent](https://discuss.elastic.co/u/pungent)\
**Post date:** [November 2, 2016, 4:41am UTC](https://discuss.elastic.co/t/null-pointer-exception-for-finding-an-integer-in-an-array/64663/1 "2016-11-02T04:41:00Z")

</div>

I have mapping of one filed is as follows in ES2.3

```
"move_in_ts": {
  "type": "integer"
}

Sample document stores data as follows:

"move_in_ts": [
        1475280000,
        1475539200,
        1475712000,
        1475884800,
        1477008000,
        1477785600
      ]

```

I have a script in my DSL query (trying to find an integer in that array)

```
"script": "if(doc['move_in_ts'] && doc['move_in_ts'].values.contains('1475280000')){return 200;}"

```

and also tried this:

```
 "script": "if(doc['move_in_ts'] && doc['move_in_ts'].contains('1475280000')){return 200;}"

```

and also tried this:

```
 "script": "if(doc['move_in_ts'] && doc['move_in_ts'].contains(1475280000)){return 200;}"

```

and also tried this:

```
 "script": "if(doc['move_in_ts'] && doc['move_in_ts'].values.contains(1475280000)){return 200;}"

```

but in above cases, I get the following error:

```
"reason": {
      "type": "null_pointer_exception",
      "reason": null
    }

```

It might be possible that this field doesn't exist at all in few documents (I cannot use filter in my use case, I need to have it in the script only)

What am I doing wrong or how to get it work?

---

<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, 10:07pm UTC](https://discuss.elastic.co/t/null-pointer-exception-for-finding-an-integer-in-an-array/64663/2 "2017-07-05T22:07:19Z")

</div>


