# NullPointerException in Elasticsearch when adding Index Pattern in kibana

**URL:** <https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817>\
**Category:** Elasticsearch\
**Created:** [June 27, 2019, 11:54am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817 "2019-06-27T11:54:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marekm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marekm/32/48924_2.png) [@marekm](https://discuss.elastic.co/u/marekm)\
**Post date:** [June 27, 2019, 11:54am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/1 "2019-06-27T11:54:05Z")

</div>

Hey,  
I noticed the following exception in the Elasticsearch logs

```
[2019-06-27T13:05:54,761][DEBUG][o.e.a.f.TransportFieldCapabilitiesIndexAction] [mpps-st-elastic-1] null: failed to execute [org.elasticsearch.action.fieldcaps.FieldCapabilitiesIndexRequest@37bdc2bd]
org.elasticsearch.transport.RemoteTransportException: [mpps-st-elastic-1][10.99.99.34:9300][indices:data/read/field_caps[index][s]]
Caused by: java.lang.NullPointerException
	at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:105) ~[elasticsearch-6.7.2.jar:6.7.2]
	at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:46) ~[elasticsearch-6.7.2.jar:6.7.2]
	at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$1.doRun(TransportSingleShardAction.java:115) [elasticsearch-6.7.2.jar:6.7.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-6.7.2.jar:6.7.2]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.7.2.jar:6.7.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]

```

This exception appears in the Elasticsearch logs when trying to add in a kibana index pattern.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/5/454589f843acb85e4424ffbfe8fa75a493973793.png)

And i can see only meta fields

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/0/00997fb8696f8c897ff4ad58dba8dd48c48509dc.png)

Definition of the index:

```
DELETE /test02

PUT test02
{
  "mappings": {
    "properties": {
      "app_name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          },
          "prefix_app_name": {
            "type": "text",
            "index_prefixes": {
              "min_chars": 1,
              "max_chars": 19
            }
          }
        }
      }
    }
  }
}
POST /test02/_doc
{
  "app_name":"my super app1"
}

```

**I suspect that the reason for the problems is using `index_prefixes`.**

When I create an index patter for an analogical index (test01), but without index\_prefixes, the problem does not appear.

```
DELETE /test01

PUT test01
{
  "mappings": {
      "properties": {
        "app_name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
}
POST /test01/_doc
{
  "app_name":"my super app1"
}

```

And I can see all fields

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bc6520d6a5db9ffe89957d1a1eb4b3e12c04b0c3.png)

I tested this on Elasticsearch 6.7.2, Kibana 6.7.2 and on Elasticsearch 6.8.0, Kibana 6.8.0.

---

<div class="post-metadata">

**Author:** ![marekm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marekm/32/48924_2.png) [@marekm](https://discuss.elastic.co/u/marekm)\
**Post date:** [June 28, 2019, 7:43am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/2 "2019-06-28T07:43:30Z")

</div>

I noticed same issue in latest Elasticsearch 7.2.0 and Kibana 7.2.0

```
[2019-06-28T09:30:23,773][DEBUG][o.e.a.f.TransportFieldCapabilitiesIndexAction] [marekm] null: failed to execute [org.elasticsearch.action.fieldcaps.FieldCapabilitiesIndexRequest@39f72cd4]
org.elasticsearch.transport.RemoteTransportException: [marekm][127.0.0.1:9300][indices:data/read/field_caps[index][s]]
Caused by: java.lang.NullPointerException
	at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:106) ~[elasticsearch-7.2.0.jar:7.2.0]
	at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:46) ~[elasticsearch-7.2.0.jar:7.2.0]
	at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$1.doRun(TransportSingleShardAction.java:113) ~[elasticsearch-7.2.0.jar:7.2.0]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:758) [elasticsearch-7.2.0.jar:7.2.0]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.2.0.jar:7.2.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]

```

Please help.  
Am I doing something incorrectly ? This is a bug in Elasticsearch / Kibana ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2019, 8:13am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/3 "2019-06-28T08:13:10Z")

</div>

Not sure but it's marked as a DEBUG log.

---

<div class="post-metadata">

**Author:** ![marekm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marekm/32/48924_2.png) [@marekm](https://discuss.elastic.co/u/marekm)\
**Post date:** [June 28, 2019, 9:24am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/4 "2019-06-28T09:24:39Z")

</div>

Thank you for your response.

Yes, it is marked as DEBUG, but.. for me **NullPointerException** means that something goes really wrong in unexpected way (I'm Java dev).

The NPE is thrown by

`org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:106)`

line 106:  
`String type = mapper.nested().isNested() ? "nested" : "object";`

For me it's means that mapper or mapper.nested is null.. and I dont known why.

In addition, Kibana still does not see the index fields and I can not implement the planned functionalities.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/b/8b88ee600398d15eb376e65e4e10e001cac3ecf0.png)

Please let me know if I am using index\_prefixes in the wrong way, or is it a Elasticsearch bug.  
Meantime I will try to make some debug Elasticsearch source code. This can be interesting adventure 😄

Regards

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2019, 11:11am UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/5 "2019-06-28T11:11:04Z")

</div>

Absolutely. Could you open an issue in elasticsearch repo? I "think" the issue is coming from Kibana though which is may be misreading the mapping but at least we should not keep an NPE in the code.

---

<div class="post-metadata">

**Author:** ![marekm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marekm/32/48924_2.png) [@marekm](https://discuss.elastic.co/u/marekm)\
**Post date:** [June 28, 2019, 12:37pm UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/6 "2019-06-28T12:37:49Z")

</div>

According to your advice, I opened a issue:

> <https://github.com/elastic/elasticsearch/issues/43741#issue-462012596>

---

<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 26, 2019, 12:37pm UTC](https://discuss.elastic.co/t/nullpointerexception-in-elasticsearch-when-adding-index-pattern-in-kibana/187817/7 "2019-07-26T12:37:52Z")

</div>

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