当前位置: 首页 > news >正文

(转)es进行聚合操作时提示Fielddata is disabled on text fields by default

根据es官网的文档执行

GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": { "field": "interests" }
    }
  }
}

这个例子时,报错

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] 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": "megacorp",
        "node": "-Md3f007Q3G6HtdnkXoRiA",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] 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 [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
    }
  },
  "status": 400
}

搜了一下应该是5.x后对排序,聚合这些操作用单独的数据结构(fielddata)缓存到内存里了,需要单独开启,官方解释在此fielddata

简单来说就是在聚合前执行如下操作

PUT megacorp/_mapping/employee/
{
  "properties": {
    "interests": { 
      "type":     "text",
      "fielddata": true
    }
  }
}

PS:执行上面操作前,先GET megacorp/_mapping/employee/查看mapping结构,然后执行上述命令,贴一下我聚合logstash读取tomcat.log到es里cilentip字段的步骤:

1.首先先GET logstash-apacheaccesslog*/_mapping/logs/查看mapping结构

PUT logstash-apacheaccesslog*/_mapping/logs/

{

  "properties": {
     "verb": {
    "type": "text",
    "norms": false,
    "fielddata": true
     }
  }

}

2、对clientip字段进行聚合

转自:http://blog.csdn.net/u011403655/article/details/71107415
 

相关文章:

  • LXD 2.0系列之二:LXD安装和配置
  • Java调用JavaFX的方法
  • ORA-04089: 无法对 SYS 拥有的对象创建触发器
  • Java获取URL中的顶级域名domain的工具类
  • CSS实现空心三角指示箭头
  • TPYBoard开发板ADC数模转换一: 初识ADC使用
  • no.4 数据和C 06
  • W3School Redis教程(安装/基本操作/高级操作/命令/官方文档/官方集群教程)
  • Go语言与数据库开发:01-06
  • js 日期计算
  • vue 请求后台数据
  • Unity3D-RayMarch-几何图元-3添加阴影
  • es6--symbol
  • 元组、函数详解
  • jQuery基本过滤选择器
  • [译]前端离线指南(上)
  • 【刷算法】从上往下打印二叉树
  • 2018一半小结一波
  • Apache的基本使用
  • Java多线程(4):使用线程池执行定时任务
  • k8s 面向应用开发者的基础命令
  • Map集合、散列表、红黑树介绍
  • markdown编辑器简评
  • React+TypeScript入门
  • vue--为什么data属性必须是一个函数
  • 成为一名优秀的Developer的书单
  • 分类模型——Logistics Regression
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 警报:线上事故之CountDownLatch的威力
  • 跳前端坑前,先看看这个!!
  • 小程序、APP Store 需要的 SSL 证书是个什么东西?
  • UI设计初学者应该如何入门?
  • #includecmath
  • #Linux(帮助手册)
  • (2015)JS ES6 必知的十个 特性
  • (Mac上)使用Python进行matplotlib 画图时,中文显示不出来
  • (二)斐波那契Fabonacci函数
  • (翻译)terry crowley: 写给程序员
  • (附源码)php投票系统 毕业设计 121500
  • (免费领源码)Python#MySQL图书馆管理系统071718-计算机毕业设计项目选题推荐
  • (算法设计与分析)第一章算法概述-习题
  • (转)chrome浏览器收藏夹(书签)的导出与导入
  • .Net 6.0 处理跨域的方式
  • .NET C# 使用 SetWindowsHookEx 监听鼠标或键盘消息以及此方法的坑
  • .net core 连接数据库,通过数据库生成Modell
  • @ 代码随想录算法训练营第8周(C语言)|Day53(动态规划)
  • @DependsOn:解析 Spring 中的依赖关系之艺术
  • @WebServiceClient注解,wsdlLocation 可配置
  • [ 转载 ] SharePoint 资料
  • [AutoSar]BSW_OS 01 priority ceiling protocol(PCP)
  • [BZOJ] 3262: 陌上花开
  • [C#][opencvsharp]opencvsharp sift和surf特征点匹配
  • [C++] Boost智能指针——boost::scoped_ptr(使用及原理分析)
  • [datastore@cyberfear.com].Elbie、[thekeyishere@cock.li].Elbie勒索病毒数据怎么处理|数据解密恢复
  • [Docker]四.Docker部署nodejs项目,部署Mysql,部署Redis,部署Mongodb