# Visual Builder Markdown - Displaying Strings

**URL:** <https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730>\
**Category:** Kibana\
**Created:** [April 26, 2018, 5:56pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730 "2018-04-26T17:56:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepperhat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepperhat/32/26586_2.png) [@pepperhat](https://discuss.elastic.co/u/pepperhat)\
**Post date:** [April 26, 2018, 5:56pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/1 "2018-04-26T17:56:08Z")

</div>

Rewriting this as I've learned a couple of things:

A bit of background:

- I'm filtering my query to only return a single result
- I'm using this to create a "document view" type visual
- I need to reference the values without knowing what they are
- I'm grouping 3 labels by Term (src\_ip, dest\_ip, app\_proto)

Using the example in the visual builder:

```
{{#each _all}}
 - {{ label }} 
{{/each}}

```

Returns:

- 192.168.130.110
- 192.168.100.15
- dns

How can i reference these individually without knowing the value? I've attempted to label the variables as source, destination, and protocol.

 ![Untitled](https://us1.discourse-cdn.com/elastic/original/3X/4/0/407527b257f30168df4046896786ab5a279dd770.png)

However, I am unable to reference these using values in the markdown such as {{source}}, {{destination}}, and {{protocol}}.

The result I'm attempting to accomplish would be a visual that looked like:

**The computer 192.168.130.110 connected to 192.168.100.15 over dns.**

At first thought, I thought it would be as simple as the code looking like

```
The computer {{source}} connected to {{destination}} over {{protocol}}.

```

But that isn't working. Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [April 27, 2018, 8:11am UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/2 "2018-04-27T08:11:30Z")

</div>

Hi,

unfortunately that's currently not possible. As you figured out, using a terms split, it will cause the values to become the keys in the `_all` object. I tried hacking around this using handlebars and the `#each` loop, but since there is also no specific checking for values, I couldn't figure out any possible workaround to achieve what you wish.

Please feel free to open a feature request for that in the Kibana GitHub repository.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![pepperhat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepperhat/32/26586_2.png) [@pepperhat](https://discuss.elastic.co/u/pepperhat)\
**Post date:** [April 27, 2018, 4:14pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/3 "2018-04-27T16:14:24Z")

</div>

Thanks for the response, I greatly appreciate these forums as I learn the elastic stack.

What I find most odd is that we /should/ be able to access these variables by index position.

```
{{#each _all}}
 - {{ label }} {{ @index }}
{{/each}}

```

Returns:

- 192.168.130.110 **0**
- 192.168.100.15 **1**
- dns **2**

And according to handlebar documentation, we /should/ be able to access these items by index position by doing ~something like this:

```
{{#each _all as |item|}}
  The computer {{item.0.label}} connected to {{item.1.label}} over {{item.2.label}}.
{{/each}}

```

Even this should still print the labels by my limited understanding (it doesn't, but also doesn't error out).

```
{{#each _all}}
 {{#each label as |thing|}}
  {{thing}}
 {{/each}}
{{/each}}

```

So chalk it up to a limited implementation?

DISCLAIMER: I know this is an experimental visualization and will gladly submit a feature request. I just want to make sure I have a good understanding of the "limitation" so submit a comprehensive feature request.

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [April 27, 2018, 5:56pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/4 "2018-04-27T17:56:43Z")

</div>

Yeah it seems like that would work, but it's not the case, because the structure is a bit different from what it seems. `_all` is not an array that you could index having those values (or objects of values). It is actually an object with the key being the actual splitted term and an object containing the label and other things, i.e. it looks something like that in your case:

```auto
_all = {
  192_168_130_110: { label: '192.168.130.110', ... },
  192_168_100_15: { label: '192.168.100.15', ... },
  dns: { label: 'dns', ... }
}

```

Since it is no array you cannot access a specific position. The `#each` helper is still able to iterate over the objects and will write a plain counter into `@index` (even though you would not be able to access the element in the object like that). It will also write the key into `@key` in each iteration.

That also why your last example wouldn't work, because `label` (that you are trying to do an `#each` on again) would only contain that one string from that one object, not from any of the other entries in that object.

I think we should actually still prefix each series, by the original variable name assigned, so that the object would look in your case like:

```auto
_all = {
   source: {
     192_168_130_110: { label: '192.168.130.110', ... },
     // here would be more objects if you would have more then 1 document per split
   },
   destination: {
     192_168_100_15: { label: '192.168.100.15', ... },
   },
   protocol: {
     dns: { label: 'dns', ... }
   }
}

```

It would still be a bit complex to access that, since you don't know the key, but you could now hack your way around it using the `#each`, since you know there is only one element in each of the subobjects.

So please feel free to reference that post when creating the feature request issue. Also to be fair, I don't think that we would put it on our roadmap in the near future, since we try to align our markdown implementations again, and I think there won't be any changes to the current implementation anymore, before we have aligned the TSVB markdown and the Kibana markdown implementation, so please don't expect that feature to be there in one of the next minor versions.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![pepperhat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pepperhat/32/26586_2.png) [@pepperhat](https://discuss.elastic.co/u/pepperhat)\
**Post date:** [April 27, 2018, 6:27pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/5 "2018-04-27T18:27:01Z")

</div>

Thanks again for another informational post. FWIW, I was able to do a very nasty hack. I likely wont be using this in production, but it was a worthwhile exercise.

```
{{#each _all}}
 {{#with source as |mysource|}}
 The computer {{../label}} connected to
 {{/with}}
 {{#with destination as |mydest|}}
 {{../label}}
 {{/with}}
 {{#with protocol as |mydest|}}
 over {{../label}}.
 {{/with}}
{{/each}}

```

Returns:

**The computer 192.168.130.110 connected to 192.168.100.15 over dns.**

EDIT: and you don't need the "as |mything|" in the with statements for this to work.

---

<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:** [May 25, 2018, 6:27pm UTC](https://discuss.elastic.co/t/visual-builder-markdown-displaying-strings/129730/6 "2018-05-25T18:27:17Z")

</div>

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