# Error: Indexing Nested Complex Object (Java High Level Rest Client)

**URL:** <https://discuss.elastic.co/t/error-indexing-nested-complex-object-java-high-level-rest-client/231130>\
**Category:** Elasticsearch\
**Created:** [May 5, 2020, 10:36am UTC](https://discuss.elastic.co/t/error-indexing-nested-complex-object-java-high-level-rest-client/231130 "2020-05-05T10:36:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jjc/32/113154_2.png) [@jjc](https://discuss.elastic.co/u/jjc)\
**Post date:** [May 5, 2020, 10:36am UTC](https://discuss.elastic.co/t/error-indexing-nested-complex-object-java-high-level-rest-client/231130/1 "2020-05-05T10:36:58Z")

</div>

Hi everyone.

I've got the following mapping with nested types:

```auto
{
  "mapping": {
    "properties": {
      "caption": {
        "type": "text"
      },
      "category": {
        "type": "text"
      },
      "description": {
        "type": "text"
      },
      "images": {
        "type": "text"
      },
      "outletid": {
        "type": "integer"
      },
      "parentshop": {
        "type": "integer"
      },
      "productid": {
        "type": "text"
      },
      "productname": {
        "type": "text"
      },
      "skus": {
        "type": "nested",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "attributes": {
            "type": "nested",
            "properties": {
              "attributeid": {
                "type": "integer"
              },
              "attributevalue": {
                "type": "text"
              },
              "keyname": {
                "type": "text"
              }
            }
          },
          "currency": {
            "type": "text"
          },
          "image": {
            "type": "text"
          },
          "inventory": {
            "properties": {
              "availability": {
                "type": "text"
              },
              "inventoryid": {
                "type": "integer"
              },
              "quantity": {
                "type": "integer"
              },
              "type": {
                "type": "text"
              }
            }
          },
          "outletid": {
            "type": "integer"
          },
          "parentshop": {
            "type": "integer"
          },
          "price": {
            "type": "integer"
          },
          "productid": {
            "type": "text"
          },
          "skuid": {
            "type": "integer"
          },
          "skuname": {
            "type": "text"
          }
        }
      },
      "type": {
        "type": "text"
      },
      "url": {
        "type": "text"
      }
    }
  }
}

```

And tried to index the following data:

```auto
{"caption":"Fresh Chicken","category":"Frozen Foods","description":"We have been producing high quality, nutritious and hygienic products for our highly valued customers and consumers at affordable prices, since 1983","outletid":4,"parentshop":1,"productid":"SdzKaEaKu5zVF6cUi3eEcBACvJXnlJs0stINvhcNHmAABZRNnSNpicH1kn5GXep9Su8xGbjVC6wa_9kSzc61bpQ_","productname":"Zartech Chicken Nugget 450G","type":"good","url":"","images":["2efd1c1e5bfd7df1fee9bed5919335fd9f4accec92d188c0ed819a337f510dfe","7ca984a384b2052936ba0b581de2e1881ce959ad1a0c0a3dcf71558ed6bda684"],"skus":[{"skuid":6,"parentshop":1,"outletid":4,"productid":"SdzKaEaKu5zVF6cUi3eEcBACvJXnlJs0stINvhcNHmAABZRNnSNpicH1kn5GXep9Su8xGbjVC6wa_9kSzc61bpQ_","skuname":"Zartech Chicken Nugget","currency":"NGN","price":45000,"image":"c0300ae486fefeb9b218fa9dc842cbfc61315e94d6d4a3b7bd88fa85d3c7f36c","active":true,"inventory":{"inventoryid":6,"quantity":300,"type":"finite","availability":"out_of_stock"},"attributes":[{"attributeid":16,"keyname":"weight","attributevalue":"0.45"}]},{"skuid":7,"parentshop":1,"outletid":4,"productid":"SdzKaEaKu5zVF6cUi3eEcBACvJXnlJs0stINvhcNHmAABZRNnSNpicH1kn5GXep9Su8xGbjVC6wa_9kSzc61bpQ_","skuname":"Sparith","currency":"NGN","price":23000,"image":"a6f7707f9c268bd0368ddb9d7a6f077b93b828351713ff48a567b59156d2eb7","active":true,"inventory":{"inventoryid":7,"quantity":340,"type":"finite","availability":"in_stock"},"attributes":[{"attributeid":7,"keyname":"weight","attributevalue":"45"}]}]}

```

But get this:  
java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.util.LinkedHashMap$Entry  
at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:833)  
at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:924)  
at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:824)  
...  
..

Is there something I'm still missing?  
Will really appreciate any ideas. Thanks.

---

<div class="post-metadata">

**Author:** ![jjc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jjc/32/113154_2.png) [@jjc](https://discuss.elastic.co/u/jjc)\
**Post date:** [May 5, 2020, 11:51am UTC](https://discuss.elastic.co/t/error-indexing-nested-complex-object-java-high-level-rest-client/231130/2 "2020-05-05T11:51:53Z")

</div>

Hi guys,  
I've narrowed the problem down to the attributes field.  
An empty array works but otherwise it fails.

Any ideas? 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:** [June 2, 2020, 11:51am UTC](https://discuss.elastic.co/t/error-indexing-nested-complex-object-java-high-level-rest-client/231130/3 "2020-06-02T11:51:57Z")

</div>

Closed on June 2, 2020, 11:51am UTC

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