# Simple vega table

**URL:** <https://discuss.elastic.co/t/simple-vega-table/354560>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 2, 2024, 4:28am UTC](https://discuss.elastic.co/t/simple-vega-table/354560 "2024-03-02T04:28:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chowpay](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@chowpay](https://discuss.elastic.co/u/chowpay)\
**Post date:** [March 2, 2024, 4:28am UTC](https://discuss.elastic.co/t/simple-vega-table/354560/1 "2024-03-02T04:28:31Z")

</div>

I finally figured out how to query and get a metric back for a nested piece of data:

```auto
GET channel_statistics_long-*/_search
{
  "_source":"",
  "query": {
    "nested": {
      "path": "components",
      "query": {
        "bool": {
          "must": [{"match_phrase": {"components.content_type": "Video"}}]
        }
      },
      "inner_hits": {
        "_source": "components.pid"
      }
    }
  }
}

```

one of the results:

```auto
{
  "took" : 1097,
  "timed_out" : false,
  "_shards" : {
    "total" : 30,
    "successful" : 30,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.5403566,
    "hits" : [
      {
        "_index" : "channel_statistics_long-2024.02.05",
        "_type" : "_doc",
        "_id" : "2a2225837d43de515f11c6337d6b6f85",
        "_score" : 1.5403566,
        "_source" : { },
        "inner_hits" : {
          "components" : {
            "hits" : {
              "total" : {
                "value" : 1,
                "relation" : "eq"
              },
              "max_score" : 1.5403566,
              "hits" : [
                {
                  "_index" : "channel_statistics_long-2024.02.05",
                  "_type" : "_doc",
                  "_id" : "2a2225837d43de515f11c6337d6b6f85",
                  "_nested" : {
                    "field" : "components",
                    "offset" : 3
                  },
                  "_score" : 1.5403566,
                  "_source" : {
                    "pid" : 201
                  }
                }
              ]
            }
          }
        }
      },

```

For the life of me. I cannot get vega to make a simple table of

datetime | pid  
datetime 201  
datetime ...

I was trying to do this with just a column of time and a column of pids:

> **[Vega-Lite "table" using text marks](https://observablehq.com/@mdeagen/vega-lite-table-using-text-marks)**
>
> I had a conversation today about the Grammar of Graphics, which led to the notion of how a table (column-and-row format that anyone who works with spreadsheets is familiar with) is just another way to represent data visually! Here, I put together a...

---

<div class="post-metadata">

**Author:** ![chowpay](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@chowpay](https://discuss.elastic.co/u/chowpay)\
**Post date:** [March 4, 2024, 2:51am UTC](https://discuss.elastic.co/t/simple-vega-table/354560/2 "2024-03-04T02:51:35Z")

</div>

I also tried :

```auto
    format: {property: "hits.hits.inner_hits.components.hits"}

```

But I get :

```auto
Cannot read properties of undefined (reading 'components')

```

So part of my problem is I cannot access the pid value:

```
              "_source" : {
                "pid" : 201

```

---

<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:** [April 1, 2024, 2:52am UTC](https://discuss.elastic.co/t/simple-vega-table/354560/3 "2024-04-01T02:52:23Z")

</div>

Closed on April 1, 2024, 2:52am UTC

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