简体   繁体   English

ElasticSearch Painless Scripts - 字段上下文不允许文本字段 - 什么上下文只添加文本字段?

[英]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.

相关问题 ElasticSearch 文本字段上的无痛过滤器脚本不起作用 - ElasticSearch painless filter script on text fields not working ElasticSearch Painless Scripts:替换除一个字段之外的所有字段 - ElasticSearch Painless Scripts: Replace all fields except one elasticsearch中的多字段文本和关键字字段 - Multi field text and keyword fields in elasticsearch 如何在弹性搜索查询的过滤上下文中以无痛脚本获取文本正文字段? - How to get the text body field in a painless script in the filter context of elastic search query? 通过文本字段聚合和排序,并在Elasticsearch中串联其他文本字段 - Aggregate and Sort by a text field and concatenate other text fields in Elasticsearch 嵌套字段的Elasticsearch完成建议上下文 - Elasticsearch completion suggester context for nested fields ElasticSearch,简单两场对比无痛 - ElasticSearch, simple two fields comparison with painless Elasticsearch:如何在脚本字段中轻松进行“分组”? - Elasticsearch : How to do 'group by' with painless in scripted fields? Elasticsearch 无痛找不到某些字段 - Elasticsearch painless cannot find some fields 如何修复关键字字段的ElasticSearch“默认情况下在文本字段上禁用字段数据” - How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM