简体   繁体   English

如何修复关键字字段的ElasticSearch“默认情况下在文本字段上禁用字段数据”

[英]How to fix ElasticSearch ‘Fielddata is disabled on text fields by default’ for keyword field

I'm getting the "Fielddata is disabled on text fields by default" on a keyword field.我在关键字字段上收到“默认情况下在文本字段上禁用字段数据”。 Below is the code.下面是代码。

{
 "aggs": {
   "agg_terms_user": {
     "terms": {
       "field": "user"
     }
   }
 }
}

The mapping for the user field is as below用户字段的映射如下

user: { type: "keyword" }

Since the user field has type set as keyword I shouldn't get the error.由于用户字段的类型设置为关键字,我不应该得到错误。 However, the error is still thrown.但是,错误仍然被抛出。

[illegal_argument_exception] Fielddata is disabled on text fields by default. [illegal_argument_exception] 默认情况下,在文本字段上禁用字段数据。 Set fielddata=true on [user] in order to load fielddata in memory by uninverting the inverted index.在 [user] 上设置 fielddata=true,以便通过反转倒排索引将 fielddata 加载到内存中。 Note that this can however use significant memory.请注意,这可能会占用大量内存。 Alternatively use a keyword field instead.或者,改用关键字字段。

I don't know what to try now.我不知道现在该尝试什么。

The comment of @Andrey Borisko was correct @Andrey Borisko 的评论是正确的

I used我用了

"field": "user.keyword" 

instead of代替

"field": "user" 

based on Nikhil's example and it worked for me.基于 Nikhil 的示例,它对我有用。

I found the reason behind the unexpected error.我找到了意外错误背后的原因。 The ES wasn't getting re-indexed properly. ES 没有得到正确的重新索引。 Once I deleted the indexed first and then recreated it then it started working like a charm.一旦我先删除了索引然后重新创建它,它就开始像魅力一样工作。

Check out the documentation in the elastic which clearly mentions that we cannot use the text field for aggregations, sorting, or scripting查看 elastic 中的文档,其中明确提到我们不能将文本字段用于聚合、排序或脚本

https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#fielddata-mapping-param https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#fielddata-mapping-param

This can be achieved with help of keyword usage.这可以在关键字使用的帮助下实现。 Try searching by尝试搜索

"field" : "user.keyword" “字段”:“user.keyword”

Facing the same issue in heartbeat application.I have solved this issue by following below steps.在心跳应用程序中面临同样的问题。我通过以下步骤解决了这个问题。

  1. stop the application [ in my case I stopped the heartbeat application]停止应用程序[在我的情况下,我停止了心跳应用程序]

  2. Delete the index related to apps.删除与应用程序相关的索引。

  3. Start the application启动应用程序

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 默认情况下,“关键字”字段在文本字段上禁用获取 Fielddata - Getting Fielddata is disabled on text fields by default for the "keyword" field 默认情况下,elasticsearch 中的文本字段禁用 Fielddata - Fielddata is disabled on text fields by default in elasticsearch 如何解决此错误默认情况下,文本字段上的字段数据已禁用。 不想添加“ fielddata”:true - How to fix this error Fielddata is disabled on text fields by default. not want to add “”fielddata“: true” 默认情况下,在文本字段上禁用字段数据 - Fielddata is disabled on text fields by default Elasticsearch:我有一个日期字段并收到错误消息:“默认情况下,文本字段上的字段数据被禁用 - Elasticsearch: I have a date field and got the error: ‘Fielddata is disabled on text fields by default 默认情况下,在文本字段上禁用 Fielddata。 设置字段数据=真 - Fielddata is disabled on text fields by default. Set fielddata=true 默认情况下,文本字段中的ElasticSearch 5.1 Fielddata是禁用的[错误:尝试在字段上使用聚合] - ElasticSearch 5.1 Fielddata is disabled in text field by default [ERROR: trying to use aggregation on field] 在Elasticsearch中,为什么会收到错误消息“默认情况下在文本字段上禁用了字段数据” - In Elasticsearch, why do I get an error message “Fielddata is disabled on text fields by default” ElasticSearch 5:按嵌套键和值排序将导致“默认情况下,文本字段的字段数据处于禁用状态” - ElasticSearch 5: sorting by nested key and value results in “Fielddata is disabled on text fields by default” 弹出搜索组按文本字段抛出错误默认情况下,在文本字段上禁用Fielddata - Elastic Search group by a text field throws error Fielddata is disabled on text fields by default
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM