Kibana Scripted Fields - Using one Value for a URL and another for the Label

I'm trying to use scripted fields on my index pattern in Kibana 6.7. I basically want to have 'field_A' referenced in the URL template, and 'field_B' referenced in the Label Template, but I must be doing something wrong because I can't get it to work.

Is this possible, and if so, how do I need to format the script?

I've read the docs and they don't really cover this, but I found another forum post that made it sound like it's possible..

URL Template:{{url_val}}

Label Template: {{label_val}}

And my script:

def url_val = doc['field_A.keyword'].value;
def label_val = doc['field_B.keyword'].value; 

Does anyone know if what I'm trying to accomplish is possible? I've read the painless documentation and none of it seems to cover what I consider to be a somewhat trivial use-case..

Hi @seth.yes, unfortunately scripted fields and field formatters don't work in the way you're trying to use them. Your script can only return a single value. Since your script doesn't have an explicit return value I'm guessing it returns the value of the last line. In the URL template and Label template you can reference that single value with {{value}}. The word value is just a convention, it does not match the variable names you use in your script. The script is actually executed in Elasticsearch, whereas the URL formatter is executed in your browser, so the two know nothing about one another. The URL formatter is not limited to scripted fields, it can be used with regular fields as well.

Thanks for the update.

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