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

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 , here is a sample doc: 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!

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.

 "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.

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 for more details about array flattening

For example, the following document

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

is indexed with

products.base_price: [1, 2]
1 Like

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