# Null reference error in scripted field

**URL:** <https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800>\
**Category:** Elasticsearch\
**Created:** [June 12, 2020, 12:42am UTC](https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800 "2020-06-12T00:42:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxtotaljunk](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@maxtotaljunk](https://discuss.elastic.co/u/maxtotaljunk)\
**Post date:** [June 12, 2020, 12:42am UTC](https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800/1 "2020-06-12T00:42:05Z")

</div>

My error is this:

[esaggs] \> Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"null\_pointer\_exception","reason":null}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"log\_data","node":"iFm60hiuQIS1BcgO9rul6w","reason":{"type":"null\_pointer\_exception","reason":null}}],"caused\_by":{"type":"null\_pointer\_exception","reason":null,"caused\_by":{"type":"null\_pointer\_exception","reason":null}}},"status":500}

and my scripted field (type string) is this:

return "0.0.0.0";

Super brain-dead test to see if I could return _anything_ and avoid the error. Nope ☹  
I must be doing something fundamentally wrong...

Thanks for any help or tips! 🙂

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [June 12, 2020, 2:46am UTC](https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800/2 "2020-06-12T02:46:58Z")

</div>

Could you share your script ?

---

<div class="post-metadata">

**Author:** ![maxtotaljunk](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@maxtotaljunk](https://discuss.elastic.co/u/maxtotaljunk)\
**Post date:** [June 12, 2020, 3:26am UTC](https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800/3 "2020-06-12T03:26:57Z")

</div>

That was it 🙂

return "0.0.0.0";

That's all it is!

---

<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 10, 2020, 3:27am UTC](https://discuss.elastic.co/t/null-reference-error-in-scripted-field/236800/4 "2020-07-10T03:27:05Z")

</div>

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