# How to access data without knowing the field names in vega?

**URL:** <https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 15, 2019, 10:34am UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511 "2019-03-15T10:34:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fernsrea](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@fernsrea](https://discuss.elastic.co/u/fernsrea)\
**Post date:** [March 15, 2019, 10:34am UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/1 "2019-03-15T10:34:59Z")

</div>

Hi!  
I wanted to know if there is a way to access data from my index (which contains multiple documents and each document contains different type of fields, for eg., one document might contain fields Aa, Ba and Ca whereas another document might contain fields Ba, Da.) without knowing the field names.  
I have pasted my code snippet which works for index containing documents which have the same fields(for eg., every document contains fields Aa, Ba, Ca and Da.)

 ![Screenshot_2019-03-15%20Kibana](https://us1.discourse-cdn.com/elastic/original/3X/1/0/10f1a795218426819eedccd4f54569bdb7c74575.png)

```
{
  "$schema": "https://vega.github.io/schema/vega/v3.3.json",
  "autosize": {
    "type": "fit",
    "resize": true
  },
  "data": [
    {
      "name": "table",
      "url": {
        "index": "xyz",
        "body": {
          "query": {
            "bool": {
              "must": [
                "%dashboard_context-must_clause%"
              ],
              "filter": [],
              "should": [],
              "must_not": [
                "%dashboard_context-must_not_clause%"
              ]
            }
          }
        },
        "size": 10
      },
      "format": {
        "property": "hits.hits"
      }
    },
// I want to make the underlying part of the code more generic
        {
      "name": "proj",
      "source": "table",
      "transform": [
      {
        "type": "project",
        "fields": ["_source.AdditionalOutput.Aa", "_source.AdditionalOutput.Ba", "_source.AdditionalOutput.Ca", "_source.AdditionalOutput.Da", "_source.AdditionalOutput.Ea"],
        "as": ["Aa", "Ba", "Ca", "Da", "Ea"]
      }]
    }, 
    {
      "name": "trans",
      "source": "proj",
      "transform": [
        {
          "type": "flatten",
          "fields": ["Aa", "Ba", "Ca", "Da", "Ea"]
        }
      ]
    }
```

---

<div class="post-metadata">

**Author:** ![monfera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monfera/32/26467_2.png) [@monfera](https://discuss.elastic.co/u/monfera)\
**Post date:** [March 15, 2019, 11:42am UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/2 "2019-03-15T11:42:12Z")

</div>

I don't think it's currently possible, @nyuriks maybe you know it otherwise?

---

<div class="post-metadata">

**Author:** ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)\
**Post date:** [March 15, 2019, 2:51pm UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/3 "2019-03-15T14:51:42Z")

</div>

As far as I know, there is no way to enumerate all available keys in an object in Vega. You might want to ask the Vega team to add either a function that returns a list of keys of an object, or a transformation that would create a list of datums, one datum per available key.

---

<div class="post-metadata">

**Author:** ![fernsrea](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@fernsrea](https://discuss.elastic.co/u/fernsrea)\
**Post date:** [March 18, 2019, 6:36am UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/4 "2019-03-18T06:36:05Z")

</div>

Thank you for your suggestion. I wanted to know how to contact the Vega team to add such function or transform.

---

<div class="post-metadata">

**Author:** ![nyuriks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nyuriks/32/26171_2.png) [@nyuriks](https://discuss.elastic.co/u/nyuriks)\
**Post date:** [March 18, 2019, 2:01pm UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/5 "2019-03-18T14:01:17Z")

</div>

See issues in [https://github.com/vega/vega](https://github.com/vega/vega)

---

<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 15, 2019, 2:01pm UTC](https://discuss.elastic.co/t/how-to-access-data-without-knowing-the-field-names-in-vega/172511/6 "2019-04-15T14:01:27Z")

</div>

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