# How can the Kibana eCommerce sample data have nested objects that can be used in Kibana visualizations?

**URL:** <https://discuss.elastic.co/t/how-can-the-kibana-ecommerce-sample-data-have-nested-objects-that-can-be-used-in-kibana-visualizations/180360>\
**Category:** Kibana\
**Created:** [May 9, 2019, 12:16pm UTC](https://discuss.elastic.co/t/how-can-the-kibana-ecommerce-sample-data-have-nested-objects-that-can-be-used-in-kibana-visualizations/180360 "2019-05-09T12:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boghy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boghy/32/45899_2.png) [@boghy](https://discuss.elastic.co/u/boghy)\
**Post date:** [May 9, 2019, 12:16pm UTC](https://discuss.elastic.co/t/how-can-the-kibana-ecommerce-sample-data-have-nested-objects-that-can-be-used-in-kibana-visualizations/180360/1 "2019-05-09T12:16:10Z")

</div>

Hi! I find a lot of resources on the web saying that kibana does not support nested objects, however in the using the sample eCommerce data it seems you can (or maybe they're not called nested objects but they seem like they are). e.g. an entry has an array of products and you can access the product's manufacturers in the visualisations.

Here is the mapping for eccomerce sample: [https://pastebin.com/rJMWjbrc](https://pastebin.com/rJMWjbrc) , here is a sample doc: [https://pastebin.com/5ksXvABn](https://pastebin.com/5ksXvABn)

I would like to achieve something similar, but can't really figure out how. Are the products in this example nested objects or are they something else?

Thanks!

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [May 9, 2019, 12:52pm UTC](https://discuss.elastic.co/t/how-can-the-kibana-ecommerce-sample-data-have-nested-objects-that-can-be-used-in-kibana-visualizations/180360/2 "2019-05-09T12:52:37Z")

</div>

Run the following command, `GET /kibana_sample_data_ecommerce/_mapping`, in Dev Tools Console to view the mapping for the `kibana_sample_data_ecommerce` index. Below is snippet of the output regarding `products`.

```auto
 "products" : {
  "properties" : {
    "_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "base_price" : {
      "type" : "half_float"
    },
    "base_unit_price" : {
      "type" : "half_float"
    },
  }
}

```

Notice how `products` is not mapped as type [nested](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html).

Since `products` is not mapped as nested, all `products` sub fields like `base_price` are flattened into a simple list of field values. This flattening looses the association between other fields in product object. But that association is not needed by the sample data set.  
See [https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html#\_how\_arrays\_of\_objects\_are\_flattened](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html#_how_arrays_of_objects_are_flattened) for more details about array flattening

For example, the following document

```auto
{
  products: [
    { 
      _id: 'example_product1',
      base_price: 1
    },
    { 
      _id: 'example_product2',
      base_price: 2
    }
  ]
}

```

is indexed with

```auto
products.base_price: [1, 2]

```

---

<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 6, 2019, 12:52pm UTC](https://discuss.elastic.co/t/how-can-the-kibana-ecommerce-sample-data-have-nested-objects-that-can-be-used-in-kibana-visualizations/180360/3 "2019-06-06T12:52:57Z")

</div>

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