[英]ElasticSearch Painless Scripts - Field Context does not allow Text Fields - What context adds just Text Fields?
I am evaluating whether I can safely use painless scripting for one of our applications.我正在评估是否可以安全地为我们的应用程序之一使用无痛脚本。 We only feel comfortable with very strict contexts.
我们只对非常严格的上下文感到舒服。 The "Field" context seems the safest because it only allows read-only against the document.
“字段”上下文似乎是最安全的,因为它只允许对文档进行只读。 However, I would like to be able to include queries against text fields but "doc values are not available as text fields by default".
但是,我希望能够包含针对文本字段的查询,但“默认情况下文档值不能作为文本字段使用”。 Does anyone know how to loosen this context slightly to allow text fields?
有谁知道如何稍微放松这个上下文以允许文本字段?
Thanks谢谢
You can access text
fields in scripts (within "Field" context) by going through params['_source']
instead of doc values which are not available for text
fields.您可以通过
params['_source']
而不是text
字段不可用的 doc 值来访问脚本中的text
字段(在“字段”上下文中)。
For example, to compute the length of a text
field you can use the following script:例如,要计算
text
字段的长度,您可以使用以下脚本:
params._source['my-text-field'].length()
ie params._source['my-text-field']
is actually the raw string that is present in your source document.即
params._source['my-text-field']
实际上是源文档中存在的原始字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.