I had an answer from Customer Success Engineering team of ES. It confirms that nested field cannot be use as 'analysis' in Kibana Discover. This means that we cannot directly build visualizations based on Nested fields directly from the Discover dashboard.
Two solutions recommended:
1/ The nested fields can be queried or returned as search results, and we can also build aggregations on top of it. The only drawback here is that nested queries might be slower, and visualizations involving nested fields need to be built in Kibana using vega custom visualization. It is not as straightforward as building using Lens, but there is a step by step tutorial in the shared link on how to do so. In short it can still be analysed in any way we would need the nested fields for.
==> This solution seems to be complicated to build.
2/ An alternative is to restructure the JSON into a flatter one, which we can then build a search experience without using nested operations. This will create more efficiency in the long term as the search operations will be significantly cheaper.
==> this solution may be easier. I used a tool to flat the nested JSON and I had a lot of fields for each field like: "consultation_1_IRM_0_volumeFlair" and "consultation_2_IRM_0_volumeFlair" ...
In Kibana, I should select all fields in relation with IRM.volumeFlair to do the analyse which it is a bad method. Each field will be treated separately while all consultation_X_IRM_X_volumeFlair fields refer to the same field which is consultation.IRM.volumeFlair.
The last solution is to generate different JSON files from one JSON file. In my example, I will generate MRI JSON file, treatement JSON file ex… for each patient JSON file. Which is not an optimized solution!
Let's take again the example of group/user used in ES website (Nested field type | Elasticsearch Guide [8.6] | Elastic).
In this case, we will generate a JSON file for GROUPs and a JSON file for USERs. In consequence, we will have two indexes: my_index_000001_group and my_index_000001_user.
How to connect these two indexes in ES? Maybe by using an aliase or we can generate a common field like an ID?
How to generate a Kibana visualisation including two fields (one field from my_index_000001_group and one field from my_index_000001_user)?
For this example, is it possible to display all the user.first for group : “fans” using Kibana Discover tool?
Thank you in advance for your help!