# Dynamic textbox from kibana dataview

**URL:** https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608
**Category:** Kibana
**Tags:** vega
**Created:** [March 27, 2023, 11:03am UTC](https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608 "2023-03-27T11:03:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)
#### Post date: [March 27, 2023, 11:03am UTC](https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608/1 "2023-03-27T11:03:36Z")

</div>

Hi community,

with directly in json embedded data a dynamic text will work like this:

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": {
    "name": "dataName",
    "values": [
      {"c1": "1", "c2": "2", "text": "TextboxText01"},
      {"c1": "1", "c2": "2", "text": "TextboxText01"},
    ]
  },

  "marks":[  
    {"type": "text",
      "encode": {
        "enter": {
          "text": {"signal": "data('dataName')[0]['text']"},
        }
      }
    },
  ]
}

```

The textbox shows 'TextboxText01'. But when I try to do the same with a Kibana-Dataview the procedure fails and it just doesn't show anything

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": {
    "name":"dataName"
    "url": {
      "index": "questions",
    }
    "format": {"property": "hits.hits"}
  },

  "marks":[  
    {"type": "text",
      "encode": {
        "enter": {
          "text": {"signal": "data('dataName')[0]['questionText']"}
        }
      }
    }
  ]
}

```

Thereby 'questionText' is one field of the index 'questions'. What would be the correct expression to show one field of the index (of one row, of course) in the textbox?

---

<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: [March 27, 2023, 12:36pm UTC](https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608/2 "2023-03-27T12:36:34Z")

</div>

Hi @joerg55

you're pretty close to that, just missing to access the `_source` path before `questionText`:

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": {
    "name":"dataName"
    "url": {
      "index": "questions",
      body: {
      }
    }
    "format": {"property": "hits.hits"}
  },

  "marks":[  
    {"type": "text",
      "encode": {
        "enter": {
          "text": {"signal": "data('dataName')[0]['_source']['questionText']"}
        }
      }
    }
  ]
}

```

In general, I would recommend to avoid to specify which fields to retrieve in the search request because:

- makes the response lighter and use less bandwidth
- retrieve only what's needed and it's easier to debug

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": {
    "name":"dataName"
    "url": {
      "index": "questions",
      body: {
        _source: false,
       fields: ["questionText"]
      }
    }
    "format": {"property": "hits.hits"}
  },

  "marks":[  
    {"type": "text",
      "encode": {
        "enter": {
          "text": {"signal": "data('dataName')[0]['fields']['questionText'][0]"} // note here the changes
        }
      }
    }
  ]
}

```

To debug this types of Vega issues I can recommend to open the `Inspect > Vega debug > Spec` panel, and copy there the full spec with values. Then paste it in the Vega playground which provides more advanced tools to debug: [Vega Editor](https://vega.github.io/editor/#/edited)

---

<div class="post-metadata">

### Author: ![joerg55](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@joerg55](https://discuss.elastic.co/u/joerg55)
#### Post date: [March 27, 2023, 1:02pm UTC](https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608/3 "2023-03-27T13:02:44Z")

</div>

@marco. Thanks a lot. I didn't think I'd ever get it right

---

<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 24, 2023, 1:03pm UTC](https://discuss.elastic.co/t/dynamic-textbox-from-kibana-dataview/328608/4 "2023-04-24T13:03:22Z")

</div>

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