Concatenate fields and add newlines

I want to combine several fields in Kibana's scripted fields editor using painless. I've got the following, but the field displays in Kibana's Discover interface with the literal \n rather than with a new line:

doc['field1'].value + '\\n' + doc['field2'].value

Secondary question: how do I check if doc['somefield'].value has a value before i include it?

You could use the elvis operator to do something only if the value is provided.

I do not think you can display scripted field results with newlines. In kibana, scripted field results are rendered as text strings so newlines or html will just be displayed as raw text without any formatting applied.

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