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

Elasticsearch keyword 中的 ignore_above配置项

1. ignore_above

关于es mapping的keyword ignore_above配置项的解释如下:

Do not index any string longer than this value. Defaults to 2147483647 so that all values would be accepted.

不会索引大于ignore_above配置值的数据,默认值2147483647字符。注意:动态mappings中自动为256。

Strings longer than the ignore_above setting will not be indexed or stored. For arrays of strings, ignore_above will be applied for each array element separately and string elements longer than ignore_above will not be indexed or stored

大于ignore_above设置的字符串将不会被索引或存储。

注意:

All strings/array elements will still be present in the _source field, if the latter is enabled which is the default in Elasticsearch.

默认所有的字符串/数组元素仍然会出现在_source字段中。

2.测试

创建索引 test_keyword,指定长度超过10的数据不索引

PUT test_keyword
{"mappings": {"properties": {"name":{"type":"keyword","ignore_above": 10}}}
}

向索引中写入数据:

PUT test_keyword/_doc/1
{"name":"1234567890"
}PUT test_keyword/_doc/2
{"name":"12345678901"
}

查询数据,结果如下:

#可以查询到数据结果
GET test_keyword/_search
{"query":{"term": {"name": "1234567890"}}
}#查询不到数据结果
GET test_keyword/_search
{"query":{"term": {"name": "12345678901"}}
}

在查询所有数据_source中可以看到“12345678901”这条数据,说明“12345678901”这条数据没有被索引。

GET test_keyword/_search{"took" : 1,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 2,"relation" : "eq"},"max_score" : 1.0,"hits" : [{"_index" : "test_keyword","_type" : "_doc","_id" : "1","_score" : 1.0,"_source" : {"name" : "1234567890"}},{"_index" : "test_keyword","_type" : "_doc","_id" : "2","_score" : 1.0,"_ignored" : ["name"],"_source" : {"name" : "12345678901"}}]}
}

http://www.lryc.cn/news/179325.html

相关文章:

  • RabbitMQ原理(一):基础知识
  • [Linux]Git
  • ChatGPT终于可以进行网络搜索 内容不再限于2021年9月前
  • uni-app:实现页面效果1
  • 归一化和标准化的联系与区别及建议
  • 数据结构--栈的实现
  • 第十章 异常
  • Rust冒泡排序
  • 麒麟信安服务器操作系统V3.5.2重磅发布!
  • 密码技术 (1) - 对称密码
  • 基于PYQT5的GUI开发系列教程【二】QT五个布局的介绍与运用
  • Cadence PCB 焊盘和封装
  • 正在等待操作系统重新启动。 请重新启动计算机以安装autocad 2024。
  • Windows电脑显示部分功能被组织控制
  • Django模板加载与响应
  • Python 内置函数详解 (4) 类型转换
  • SpringBoot之Web原生组件注入
  • [每周一更]-(第64期):Dockerfile构造php定制化镜像
  • 若依不分离+Thymeleaf select选中多个回显
  • OCX 添加方法和事件 HTML调用ocx函数及回调 ocx又调用dll VS2017
  • 苹果iPhone手机使用草柴返利APP查询领取淘宝天猫京东优惠券如何取消关闭粘贴商品链接时的弹窗提示?
  • 主机安装elasticsearch后无法登陆
  • 【面试题精讲】JavaSe和JavaEE的区别
  • React 全栈体系(十五)
  • 【逆向】(c++)分析pe结构,拉伸pe结构,缩小pe结构
  • PyTorch实战:常用卷积神经网络搭建结构速览
  • 排序算法之【快速排序】
  • 声明式调用 —— SpringCloud OpenFeign
  • LuatOS-SOC接口文档(air780E)-- fota - 底层固件升级
  • 第二章 Introduction