# How to use our index name in data section in vega?

**URL:** https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416
**Category:** Kibana
**Tags:** vega
**Created:** [May 11, 2022, 5:59am UTC](https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416 "2022-05-11T05:59:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Arifullah](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@Arifullah](https://discuss.elastic.co/u/Arifullah)
#### Post date: [May 11, 2022, 5:59am UTC](https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416/1 "2022-05-11T05:59:26Z")

</div>

I want to create tree layout graph in vega from my index which its name is 123. the index has many fields but I want only two fields of the index to be showed in the graph which is A and B. The question is how to use my index name in data section of the query. an example of tree layout query is presented below. so please help me how to add my index name in the data section in below query.

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "description": "An example of Cartesian layouts for a node-link diagram of hierarchical data.",
  "width": 600,
  "height": 1600,
  "padding": 5,

  "signals": [
    {
      "name": "labels", "value": true,
      "bind": {"input": "checkbox"}
    },
    {
      "name": "layout", "value": "tidy",
      "bind": {"input": "radio", "options": ["tidy", "cluster"]}
    },
    {
      "name": "links", "value": "diagonal",
      "bind": {
        "input": "select",
        "options": ["line", "curve", "diagonal", "orthogonal"]
      }
    },
    {
      "name": "separation", "value": false,
      "bind": {"input": "checkbox"}
    }
  ],

  "data": [
    {
      "name": "tree",
      "url": "data/flare.json",
      "transform": [
        {
          "type": "stratify",
          "key": "id",
          "parentKey": "parent"
        },
        {
          "type": "tree",
          "method": {"signal": "layout"},
          "size": [{"signal": "height"}, {"signal": "width - 100"}],
          "separation": {"signal": "separation"},
          "as": ["y", "x", "depth", "children"]
        }
      ]
    },
    {
      "name": "links",
      "source": "tree",
      "transform": [
        { "type": "treelinks" },
        {
          "type": "linkpath",
          "orient": "horizontal",
          "shape": {"signal": "links"}
        }
      ]
    }
  ],

  "scales": [
    {
      "name": "color",
      "type": "linear",
      "range": {"scheme": "magma"},
      "domain": {"data": "tree", "field": "depth"},
      "zero": true
    }
  ],

  "marks": [
    {
      "type": "path",
      "from": {"data": "links"},
      "encode": {
        "update": {
          "path": {"field": "path"},
          "stroke": {"value": "#ccc"}
        }
      }
    },
    {
      "type": "symbol",
      "from": {"data": "tree"},
      "encode": {
        "enter": {
          "size": {"value": 100},
          "stroke": {"value": "#fff"}
        },
        "update": {
          "x": {"field": "x"},
          "y": {"field": "y"},
          "fill": {"scale": "color", "field": "depth"}
        }
      }
    },
    {
      "type": "text",
      "from": {"data": "tree"},
      "encode": {
        "enter": {
          "text": {"field": "name"},
          "fontSize": {"value": 9},
          "baseline": {"value": "middle"}
        },
        "update": {
          "x": {"field": "x"},
          "y": {"field": "y"},
          "dx": {"signal": "datum.children ? -7 : 7"},
          "align": {"signal": "datum.children ? 'right' : 'left'"},
          "opacity": {"signal": "labels ? 1 : 0"}
        }
      }
    }
  ]
}

```

---

<div class="post-metadata">

### Author: ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)
#### Post date: [May 11, 2022, 2:35pm UTC](https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416/2 "2022-05-11T14:35:22Z")

</div>

If you follow the [Vega tutorial](https://www.elastic.co/guide/en/kibana/current/vega.html#vega-tutorial-create-a-stacked-area-chart) you'll see that the `data` key is in fact an object that encodes a `url` parameter with the `query` that you want to do against Elasticsearch and an `index` parameter.

This is a screenshot from one of the vega visualization included with the sample data

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

---

<div class="post-metadata">

### Author: ![Arifullah](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@Arifullah](https://discuss.elastic.co/u/Arifullah)
#### Post date: [May 12, 2022, 6:46am UTC](https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416/3 "2022-05-12T06:46:16Z")

</div>

thanks from help

---

<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: [June 9, 2022, 6:46am UTC](https://discuss.elastic.co/t/how-to-use-our-index-name-in-data-section-in-vega/304416/4 "2022-06-09T06:46:46Z")

</div>

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