0

An ElasticSearch index contains a Product entity. Each product has an array of Components entities. A component may contain an optional outOfStock field.

Given the following example:

"Product": 
   "name": "blue_toy"
   "Components": [
    {
       "partnumber": "100"
       "supplier": "smith and sons"
       "outOfStock": "true"
    }

    {
       "partnumber": "200"
       "supplier": "smith and sons"

    }]
}


"Product": 
   "name": "green_toy"
   "Components": [
    {
       "partnumber": "300"
       "supplier": "smith and sons"
    }]
}

blue_toy cannot be built because one part is unavailable.

I want to show in a chart how many products cannot be build, as opposed to the number which can be built.

Given that if even one component is unavailable the entire product cannot be built, in the above example to distribution would be 50% - 50%.

Note that this is different than how many components of the total set are are of stock (which would be 33% - 66%).

In essense, the question is how to mark or flag a root entity based on the contents of one of its nested entities.

How could one do this in Kibana?

Thanks

user1052610
  • 4,440
  • 13
  • 50
  • 101

1 Answers1

0

I dont know if it will fit in your exemple but i once did have a similar problem which I solved with the "copy_to" parameter.

In your exemple, you have to change the mapping of Product to add a "copy_to" to your "outOfStock" field.

it'll create a field (with a specified name) in the root document with your "outOfStock" value.

This field will be add at indexing time and you can say that if the field created by the "copy_to" is "true" then the Product cannot be built.

See: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-core-types.html

Samy Elaiassi
  • 516
  • 3
  • 12