Reputation: 10270
I am trying to get scripted fields in Kibana to work.
I have two fields in my documents, customer
and site
I'd like to create a new scripted field called friendly_name
which is customer+" "+site
I've tried
return doc["customer"].value + " "+doc["site"].value
and it doesn't yield any results.
I've even tried just return 1
to see if I can get anything to return.
How can I get this to work?
Upvotes: 0
Views: 1960
Reputation: 52368
Scripted fields work with doc_values only and I am guessing that, since this doesn't work for you, your customer
and site
field are text
fields.
From https://www.elastic.co/blog/using-painless-kibana-scripted-fields:
Both Painless and Lucene expressions operate on fields stored in doc_values. So for string data, you will need to have the string to be stored in data type keyword.
So, you either define your two fields to be keyword
or you add a subfield to them and in your scrip you use customer.keyword
and site.keyword
. And the changed mapping should be:
"customer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
Upvotes: 3