# Occasionally missing fields in custom plugin

**URL:** <https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217>\
**Category:** Elasticsearch\
**Created:** [March 2, 2018, 9:39am UTC](https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217 "2018-03-02T09:39:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![batenburg](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@batenburg](https://discuss.elastic.co/u/batenburg)\
**Post date:** [March 2, 2018, 9:39am UTC](https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217/1 "2018-03-02T09:39:40Z")

</div>

I'm running into a nasty bug where the params HashMap provided to the newScript function is somewhat incomplete. I can't find any issue like this and considered filing a bug, but I don't know how to reproduce it.

**Elasticsearch version** : Version: 5.3.0, Build: 3adb13b/2017-03-23T03:31:50.652Z, JVM: 1.8.0\_92-internal

**Plugins installed** : [CustomPlugin, analysis-icu, x-pack]

**JVM version** (`java -version`): openjdk version "1.8.0\_92-internal"  
OpenJDK Runtime Environment (build 1.8.0\_92-internal-alpine-r1-b14)  
OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode)

**OS version** (`uname -a` if on a Unix-like system):

- Linux f973639e3af1 4.9.75-linuxkit-aufs #1 SMP Tue Jan 9 10:58:17 UTC 2018 x86\_64 Linux (dockerized, local)
- Linux telc1 3.13.0-139-generic #188-Ubuntu SMP Tue Jan 9 14:43:09 UTC 2018 x86\_64 x86\_64 x86\_64 GNU/Linux (server, no docker)

**Description of the problem including expected versus actual behavior** :  
While processing a script\_score or script\_fields elasticsearch is not passing the full information to the newScript function of our custom plugin. This is appear to happen randomly, the same plugin is used in script\_score and script\_fields and often only one of those is missing some fields. More specifically it appears that the size of one of the HashMaps in the params is wrong:

From a debug on org/elasticsearch/elasticsearch/5.3.0/elasticsearch-5.3.0-sources.jar!/org/elasticsearch/script/NativeScriptEngineService.java:75 I see that the HashMap has 13 items (as expected), but the size is reported to be 11. It always seem to happen to either tireFront or tireRear. When calculating the score I might be using the budget value which is then missing (I might get lucky and the missing 2 fields might not be necessary).

```auto
vars.get("tireFront") = {HashMap@13585} size = 11
 0 = {HashMap$Node@13593} "normal" -> "14"
 1 = {HashMap$Node@13594} "year" -> "31052017"
 2 = {HashMap$Node@13595} "id" -> "P"
 3 = {HashMap$Node@13596} "rimSize" -> "15"
 4 = {HashMap$Node@13597} "serviceLifeCorrection" -> "0.52"
 5 = {HashMap$Node@13598} "premium" -> "14"
 6 = {HashMap$Node@13599} "tireType" -> "R"
 7 = {HashMap$Node@13600} "width" -> "185"
 8 = {HashMap$Node@13601} "serviceLife" -> "65000.0"
 9 = {HashMap$Node@13602} "speedIndex" -> "T"
 10 = {HashMap$Node@13603} "tireSize" -> "P18560TR15"
 11 = {HashMap$Node@13604} "height" -> "60"
 12 = {HashMap$Node@13605} "budget" -> "14"

```

**Steps to reproduce** :

Unfortunately I can't share the plugin or the elasticsearch request due to IP restrictions. I'm not sure how to reproduce it any other way.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [March 2, 2018, 6:24pm UTC](https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217/2 "2018-03-02T18:24:54Z")

</div>

Don't have much insight into your problem, but is perhaps threading an  
issue? Can you use an immutable map and see if write exceptions after the  
fact occur?

---

<div class="post-metadata">

**Author:** ![batenburg](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@batenburg](https://discuss.elastic.co/u/batenburg)\
**Post date:** [March 5, 2018, 11:56am UTC](https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217/3 "2018-03-05T11:56:31Z")

</div>

I'll look into that and see if it happens. 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:** [April 2, 2018, 11:56am UTC](https://discuss.elastic.co/t/occasionally-missing-fields-in-custom-plugin/122217/4 "2018-04-02T11:56:57Z")

</div>

Closed on April 2, 2018, 11:56am UTC

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