关于elasticsearch的terms查询超过最大terms数

当我使用es的terms查询时,报错了这段内容。

python 复制代码
failed to create query: The number of terms [80306] used in the Terms
Query request has exceeded the allowed maximum of [65536]. This
maximum can be set by changing the [index.max_terms_count] index level
setting.

根据资料,这是es对terms的数量限制。最高限制为65536,。

要解决这个问题,我研究了两种方法:

  1. 改变最大terms数量
powershell 复制代码
curl --location --request PUT 'xxxxx/_settings' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Content-Type: application/json' \
--data '{
  "index.max_terms_count": 262144
}'
  1. 将单个terms分为多个terms,按照max_terms_count的数量,将terms的值数组切成多个数组,通过should的方式拼起来进行查询。

总结:

目前我用的这两种方法都可以实现同样的效果,当前我使用的数组长度大约是8w个,在查询速度上两个的速度基本相同。

参考资料:

  1. Terms query
  2. Elasticsearch Query DSL之Term level queries
  3. 第三章 Elasticsearch基础搜索(一)
相关推荐
万邦科技Lafite19 小时前
阿里巴巴商品详情API返回值:电商精准营销的关键
大数据·数据库·人工智能·电商开放平台
tc&19 小时前
为什么 Kamailio 模块封装的 MySQL 函数能有效防范 SQL 注入?
数据库·sql·mysql·网络攻击模型·kamailio
cookqq20 小时前
Java+MySQL时区难题-Date自动转换String差8小时
数据库·mysql
sugarzhangnotes20 小时前
MySQL 8.0升级中的字符集陷阱与解决方案
android·数据库·mysql
BD_Marathon20 小时前
MyBatis核心配置文件之mappers
java·数据库·mybatis
float_六七20 小时前
数据库管理系统(DBMS) 的核心组成部分
数据库·oracle
科技块儿20 小时前
内网系统IP离线数据库搭建与维护完整方案
数据库·网络协议·tcp/ip
小徐不徐说20 小时前
避坑指南:Qt 中 Lambda 表达式崩溃原因与高效使用实践
数据库·c++·qt·面试
chirrupy_hamal20 小时前
WAL 记录的内容变种
数据库·postgresql
1***438020 小时前
技术文章大纲:用MySQL玩转数据可视化数据库连接与数据查询基础
数据库·mysql·信息可视化