# Kibana Table Visualization of documents with nested array of JSON

**URL:** https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740
**Category:** Kibana
**Created:** [September 21, 2021, 2:48pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740 "2021-09-21T14:48:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fefontana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fefontana/32/62843_2.png) [@fefontana](https://discuss.elastic.co/u/fefontana)
#### Post date: [September 21, 2021, 2:48pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/1 "2021-09-21T14:48:44Z")

</div>

Hi, I have the following json documents stored in Elasticsearch. It is a json with a nested array with json items:

> {  
> "took": 40,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 1,  
> "successful": 1,  
> "skipped": 0,  
> "failed": 0  
> },  
> "hits": {  
> "total": {  
> "value": 1,  
> "relation": "eq"  
> },  
> "max\_score": 1.9924302,  
> "hits": [  
> {  
> "\_index": "ff\_sms",  
> "\_type": "\_doc",  
> "\_id": "60df32454534910028e35459",  
> "\_score": 1.9924302,  
> "\_source": {  
> "type": "prueba",  
> "sentBySistarBank": false,  
> "deliveryReport": false,  
> "canceled": false,  
> "irisIxId": "60df32454534910028e35454",  
> "client": "test\_iris",  
> "app": "postman",  
> "cellNumber": 59892300727,  
> "text": "prioridad 1",  
> "creationDate": "2021-07-02T15:35:33.458Z",  
> "priority": 1,  
> "log": [  
> {  
> "error": false,  
> "date": "2021-07-02T15:35:33.458Z",  
> "step": "recibidoAPI"  
> },  
> {  
> "error": false,  
> "date": "2021-07-02T15:35:33.848Z",  
> "step": "agregadoKafka"  
> }  
> ],  
> "\_\_v": 1  
> }  
> }  
> ]  
> }  
> }

I'm trying to build a Kibana "Aggregation based" visualization (not Lens) using a table and "Terms" aggregation for each "Bucket" in Kibana Data menu.  
I don't understand why the table is repeating rows when using items of the inner array. The attached image is showing the issue:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/f/ff9f2071c92413b67ee70506121a1003939e62fd.png)

---

<div class="post-metadata">

### Author: ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)
#### Post date: [September 21, 2021, 3:04pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/2 "2021-09-21T15:04:52Z")

</div>

Hi @fefontana ,

I see in your picture that you are using 4 distinct aggregations as `Split by row` there.  
These splits will first divide each row of the table by `irisIxId.keyword`, then by `log.date`, and so on so forth: assuming you've set size 100 for all the other split aggregations, you can have "potentially" 100 x 100 x 100 rows for each `irisIxId.keyword`.  
In your example the first 2 columns are the same for each `irisIxId.keyword`, but there are 2 documents with different `log.step.keyword` value.

---

<div class="post-metadata">

### Author: ![fefontana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fefontana/32/62843_2.png) [@fefontana](https://discuss.elastic.co/u/fefontana)
#### Post date: [September 21, 2021, 3:14pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/3 "2021-09-21T15:14:09Z")

</div>

Ok, I understand your point, but is there any way to include all the listed columns in the table without having repeated rows ?.

---

<div class="post-metadata">

### Author: ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)
#### Post date: [September 21, 2021, 3:52pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/4 "2021-09-21T15:52:19Z")

</div>

But rows are not really repeated, you are visualizing data aggregations, not just raw documents.  
If you want to show only 1 aggregated row per `irisIxId.keyword` you can set the size of all the other splits aggregations to 1, but then you'll only see the top value there.

If you're interested in raw documents, you can probably check Discover and use saved searched to show a table of documents in your dashboard.

---

<div class="post-metadata">

### Author: ![fefontana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fefontana/32/62843_2.png) [@fefontana](https://discuss.elastic.co/u/fefontana)
#### Post date: [September 23, 2021, 4:31pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/5 "2021-09-23T16:31:40Z")

</div>

Sorry @Marco_Liberati but your solution doesn't work in order to get a table like the image below. I need a really simple thing, a table showing only the filtered document and a unique item of the inner array. This issue doesn't occur if the document doesn't contain an inner array. I understand data aggregations in Kibana but I don't want to include in the table not existing rows. How can I do that in Kibana with this JSON data source ?. Do I have to transform the JSON ?.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d17d0d6a99e457f40c00377339149bc5623294b8.png)

Also tried this visualization in Lens after modify one value of the field "error" in the inner array, and I'm getting the same behavior. See the image below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/78ae9987e8a04ee6172dedeb76aaef68c3ebbd84.png)

---

<div class="post-metadata">

### Author: ![fefontana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fefontana/32/62843_2.png) [@fefontana](https://discuss.elastic.co/u/fefontana)
#### Post date: [September 24, 2021, 8:42pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/6 "2021-09-24T20:42:13Z")

</div>

With a nested array of JSON's, the only way I found to build a Kibana table showing columns taken from the first level and the second level of the document was to split each document in the following way:

ORIGINAL DOC:

```auto
[
  {
    "field1": "Test1",
    "field2": "DescrTest1",
    "array": [
      {
        "fieldA": "error1",
        "fieldB": "message1"
      },
      {
        "fieldA": "error2",
        "fieldB": "message2"
      }
    ]
  }
]

```

SPLIT DOC:

```auto
[
  {
    "field1": "Test1",
    "field2": "DescrTest1",
    "array_fieldA": "error1",
    "array_fieldB": "message1"
  },
  {
    "field1": "Test1",
    "field2": "DescrTest1",
    "array_FieldA": "error2",
    "array_FieldB": "message2"
  }
]

```

The main disadvantage of this approach is to repeat all the level 1 fields for each item of the level 2.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/9/792f7280e40b73f5fa220a1f06525764fc8c71f5.png)

---

<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: [October 22, 2021, 8:42pm UTC](https://discuss.elastic.co/t/kibana-table-visualization-of-documents-with-nested-array-of-json/284740/7 "2021-10-22T20:42:19Z")

</div>

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