# Getting error while processing Nested Document :org.elasticsearch.hadoop.mr.WritableArrayWritable cannot be cast to org.apache.hadoop.io.MapWritable

**URL:** <https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [August 22, 2019, 3:40pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359 "2019-08-22T15:40:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas2](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Srinivas2](https://discuss.elastic.co/u/Srinivas2)\
**Post date:** [August 22, 2019, 3:40pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/1 "2019-08-22T15:40:27Z")

</div>

Hi Team,  
I am creating an external table on a nested JSON document looks like below.

```
{
  "rootcol1": "val1",
  "rootcol2": "vla2",
  "rootcol3": "val2",
  "rootcol4": "val3",
  "rootcol5": [
    {
      "childcol1": "vla5",
      "childcol2":[
	{"innercol1":"innervalue1"},
	{"innercol2":"innervalue2}"
      ]
    }
    ]
}

```

Below is the create table statement .

```
create external table elasticserach_pool_59(rootcol1 STRING,rootcol2 STRING,rootcol3 STRING,childcol1 STRING) 
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES(
   'es.nodes'='Endpoint Name', 
   'es.port'='port',
   'es.resource'='indexname' , 
   'es.nodes.wan.only' = 'true',
   'es.nodes.discover'='true',
'es.mapping.names'='rootcol1 :rootcol1 ,rootcol2 :rootcol2 ,rootcol3:rootcol3,childcol1:rootcol5.childcol1',
'es.read.field.as.array.exclude'='rootcol5.*'
);

```

I am getting the error when I execute select statement.

`:org.elasticsearch.hadoop.mr.WritableArrayWritable cannot be cast to org.apache.hadoop.io.MapWritable`

I tried with exclude option as well , but getting same exception. If I am not including the child columns ,I able to see the Data without any issue.  
Please assist me on this issue. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![varunakuraju](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@varunakuraju](https://discuss.elastic.co/u/varunakuraju)\
**Post date:** [August 22, 2019, 4:00pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/2 "2019-08-22T16:00:14Z")

</div>

I am new to this as well but i created external table like this  
create external table vgsale\_es(  
rank int,  
....  
stored by "org.elasticsearch.hadoop.hive.EsStorageHandler"  
tblproperties("es.resource"="vgsale\_es/vgsale",  
"es.index.auto.create"="true",  
"es.nodes"="localhost");

But the file i uploaded is csv

---

<div class="post-metadata">

**Author:** ![Srinivas2](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Srinivas2](https://discuss.elastic.co/u/Srinivas2)\
**Post date:** [August 22, 2019, 4:03pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/3 "2019-08-22T16:03:39Z")

</div>

Thanks Varun.  
But I am using ES-SPARK for index the document and creating External table to retrieve the data. But I am indexing the Nested Json Document( Please see my document in my quesition) , not CSV file.

---

<div class="post-metadata">

**Author:** ![varunakuraju](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@varunakuraju](https://discuss.elastic.co/u/varunakuraju)\
**Post date:** [August 22, 2019, 4:11pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/4 "2019-08-22T16:11:27Z")

</div>

The table that i created is ES-Hive to create index in elasticsearch.

---

<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:** [August 23, 2019, 5:04pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/5 "2019-08-23T17:04:34Z")

</div>

Hi @Srinivas2, can you share the result of the index mapping endpoint for the index on Elasticsearch you are trying to query? I'm thinking there might be a misalignment of your `es.read.field.as.array.exclude` setting compared to the index mapping you're trying to read.

---

<div class="post-metadata">

**Author:** ![Srinivas2](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Srinivas2](https://discuss.elastic.co/u/Srinivas2)\
**Post date:** [August 23, 2019, 6:43pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/6 "2019-08-23T18:43:45Z")

</div>

@james.baiera Thanks James.  
Below is the mapping (I have updated the document as well). I have manipulated document (removed the some of the fields )as well. However the original document looks like same here. I need to extract parent documents along with child columns so I used DOT notation in es.mapping.names .

```
{
  "test_nested" : {
    "mappings" : {
      "1" : {
        "properties" : {
          "rootcol1" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "rootcol2" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "rootcol3" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "rootcol4" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "rootcol5" : {
            "properties" : {
              "childcol1" : {
                "type" : "text",
                "fields" : {
                  "keyword" : {
                    "type" : "keyword",
                    "ignore_above" : 256
                  }
                }
              },
              "childcol2" : {
                "properties" : {
                  "innercol1" : {
                    "type" : "text",
                    "fields" : {
                      "keyword" : {
                        "type" : "keyword",
                        "ignore_above" : 256
                      }
                    }
                  },
                  "innercol2" : {
                    "type" : "text",
                    "fields" : {
                      "keyword" : {
                        "type" : "keyword",
                        "ignore_above" : 256
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![Srinivas2](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Srinivas2](https://discuss.elastic.co/u/Srinivas2)\
**Post date:** [August 27, 2019, 1:20pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/7 "2019-08-27T13:20:31Z")

</div>

@james.baiera : Hi James , Did you get chance look into issue. I created an index with mapping as rootcol5 as nested type , but I am getting the same error. I used es.read.filed.as.array.include also but no luck. I Followed the Official doc for these as **rootcol5** contains **array of Objects**.

Could you please assist me on this.

Thanks  
Srinivas

---

<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:** [September 24, 2019, 1:20pm UTC](https://discuss.elastic.co/t/getting-error-while-processing-nested-document-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-mapwritable/196359/8 "2019-09-24T13:20:32Z")

</div>

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