Visualize based on grouped documents using element value

Hey, assuming I have the following documents that represent passengers:

{‘name’: ‘Mario’, preferable_seats: [2,3,4], car: 2}
{‘name’: ‘Luigi’, preferable_seats: [1,4,5], car: 1, }
{‘name’: ‘Toad’, preferable_seats: [1, 2], car: 2, }

Now, this is what I have indexed in elasticsearch but when working with the data and creating visualizations in Kibana I would like to actually refer to cars. So basically I want for example to:

  • Create a pie chart of the number of passengers in each car
  • Show overall preferable seats per car. So for example, car 2 list will be: [1, 2, 3, 4]

Now to the question - what would be the best way to tackle this?: Create car documents prior to indexing the data or do it directly in Kibana? If in KIbana, it would be nice if someone could show me how for example I can do “Create a pie chart of the number of passengers in each car".

If you're going to index the documents as follows:

POST cars/_doc/1
{"name": "Mario", "preferable_seats": [2,3,4], "car": 2}

POST cars/_doc/2
{"name": "Luigi", "preferable_seats": [1,4,5], "car": 1 }

POST cars/_doc/3
{"name": "Toad", "preferable_seats": [1, 2], "car": 2 }

You can create a Kibana index pattern named cars.

If the number of distinct cars is not extremely high, the following visualizations should make it.

This will show the number of preferences per car, per seat.

Amazing. Thank you very much for the detailed answer :slight_smile:

1 Like

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