ElasticSearch 错误 Fielddata is disabled on text fields by default. Set fielddata=true 解决办法

这篇具有很好参考价值的文章主要介绍了ElasticSearch 错误 Fielddata is disabled on text fields by default. Set fielddata=true 解决办法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

情况:
页面查询ES数据,Java查询报这个错误,但是,通过打印的语句,构建curl
查询时候又是正常的,这就让我很费解。

报错信息:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "aaa_bbb_info_2022-09-27",
        "node": "CqKuZyFxSYqCsgaXM7jX2A",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
    }
  },
  "status": 400
}

网上的解决办法:
https://blog.csdn.net/qq_16417621/article/details/105859887

这个解决办法其实是正确的,但是,有个前提条件,我们已经导入过模板,所以,可以直接修改模板
而且,这个帖子中的语句,是基于 ES7 的。我所在环境是ES5的,所以,加fielddata=true配置时,还报错。

具体解决办法:
我直接重新创建模板,然后,重新刷一次数据,解决问题。

导入模板语句:

curl -X PUT -u elastic:123456  "http://127.0.0.1:9200/_template/aaa_bbb_info_temple" -H 'Content-Type: application/json' -d'{"template":"aaa_bbb_*","settings":{"index":{"mapping":{"ignore_malformed":"true"},"refresh_interval":"20s","number_of_shards":"5","translog":{"flush_threshold_size":"512mb","sync_interval":"60s","durability":"async"},"number_of_replicas":"1"}},"mappings":{"default":{"properties":{"aaa":{"store":true,"type":"keyword"}}}}}'

查询导入是否成功:文章来源地址https://www.toymoban.com/news/detail-599220.html

curl -H "Content-Type:application/json" -XGET -u elastic:123456 '192.168.92.82:9222/_template/aaa_bbb_info_temple' > aaa_bbb_info_temple.txt

到了这里,关于ElasticSearch 错误 Fielddata is disabled on text fields by default. Set fielddata=true 解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包