[英]Scripted Field Kibana Not Working
I am trying to get scripted fields in Kibana to work. 我正在尝试使Kibana中的脚本字段起作用。
I have two fields in my documents, customer
and site
我的文档中有两个字段,
customer
和site
I'd like to create a new scripted field called friendly_name
which is customer+" "+site
我想创建一个名为
friendly_name
的新脚本字段,该字段是customer+" "+site
I've tried return doc["customer"].value + " "+doc["site"].value
我尝试过
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. 我什至尝试
return 1
来查看是否可以返回任何东西。
How can I get this to work? 我该如何工作?
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. 脚本字段仅与doc_values一起使用,我猜想,由于这不适用于您,因此
customer
和site
字段是text
字段。 From https://www.elastic.co/blog/using-painless-kibana-scripted-fields : 从https://www.elastic.co/blog/using-painless-kibana-scripted-fields :
Both Painless and Lucene expressions operate on fields stored in doc_values.
无痛和Lucene表达式都对doc_values中存储的字段进行操作。 So for string data, you will need to have the string to be stored in data type keyword.
因此,对于字符串数据,您将需要将字符串存储在data type关键字中。
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
. 因此,您可以将两个字段定义为
keyword
或者向它们添加一个子字段,并在site.keyword
使用customer.keyword
和site.keyword
。 And the changed mapping should be: 更改后的映射应为:
"customer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.