# Use Visualization with nested objects

**URL:** <https://discuss.elastic.co/t/use-visualization-with-nested-objects/248716>\
**Category:** Elasticsearch\
**Created:** [September 15, 2020, 5:21pm UTC](https://discuss.elastic.co/t/use-visualization-with-nested-objects/248716 "2020-09-15T17:21:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BkQc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkqc/32/73699_2.png) [@BkQc](https://discuss.elastic.co/u/BkQc)\
**Post date:** [September 15, 2020, 5:21pm UTC](https://discuss.elastic.co/t/use-visualization-with-nested-objects/248716/1 "2020-09-15T17:21:11Z")

</div>

I have an index which is comprised of entries like the following.  
Is it possible to create Visualization that respects the nested nature of it?  
When I tried, with the X-Axis being SiteId and a split on Count and DistinctCountthis data, the result would be

Site1 =\> Count: 1 / Distinct: 2  
Site2 =\> Count: 2 / Distinct: 3  
Site3 =\> Count: 2 / Distinct: 1

What I would expect is  
Site1 =\> Count: 1 / Distinct: 1  
Site2 =\> Count 2 / Distinct: 2  
Site3 =\> Count: 2 / Distinct: 1

I understand this is because Elastic flattens the object.  
I found [an article that says we can query nested objects](https://www.educba.com/kibana_query/) with a specific syntax (that I didn't get to work yet in Discover) but I can't find anything about visualization.

```
[
{ "_source": {
  "UserIds": [
    { "SiteId": 1, "UserId": "abcd" },
    { "SiteId": 2, "UserId": "efgh" }
]}},
{ "_source": {
  "UserIds": [
    { "SiteId": 2, "UserId": "ijkl" },
    { "SiteId": 3, "UserId": "abcd" }
  ]}},
{ "_source": {
  "UserIds": [
    { "SiteId": 3, "UserId": "abcd" }
  ]}}
]
```

---

<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 13, 2020, 5:21pm UTC](https://discuss.elastic.co/t/use-visualization-with-nested-objects/248716/2 "2020-10-13T17:21:12Z")

</div>

Closed on October 13, 2020, 5:21pm UTC

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