Url field formatter to exploit multiple fields


(Mauro Michielon) #1

Is it possible to have url formatted fields with label from another field?

something equivalent to html: < a href="fieldUrl">fieldLabel < /a >


(Peter Pisljar) #2

i guess you could use a scripted field to generate something like this.

return '<a href="' + doc['fieldUrl'].value + '">' + doc['fieldLabel'].value + '</a>';

hope this gives you some ideas.


(Mauro Michielon) #3

brilliant, thank you :slight_smile:

however, this does not work:
return '< a href="' + doc['dataUri'].value + ' " > ' + doc['dataTitle'].value + '< /a >';
while this one does:
return '< a href="' + params['_source']['dataUri'] + ' ">' + params['_source']['dataTitle'] + '< /a >';

the returned string is something similar to:
< a href="www.google.com">link to google< / a>

The problem is how to use the html code to display it as clickable link, in a table visualization for instance.
I have tried to use the Url formatter playing with "Url Template" and "Label Template" settings with no positive outcome.


(Peter Pisljar) #4

i don't think this will be possible.

you could use url formatter but you won't get to exactly what you are looking for:

  • edit the dataUri field in managenent
  • set it to use URL formatter
  • in the Label template enter your label (a fixed one ... something like my link) if you don't want the url to be visible in the table.

but, you can't use another field to set the label ...
even if this would be scripted field which would produce something like my label:my url there is no way to split this in the url template/label template as {{value}} at those fields represents the whole field value.


(Peter Pisljar) #5

might be worth opening a feature request on github.


(system) #6

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