关于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基础搜索(一)
相关推荐
2201_7610405919 小时前
Golang怎么安全关闭channel_Golang channel关闭教程【通俗】
jvm·数据库·python
jerryinwuhan19 小时前
基于结构可控性的给水管网传感器布点选择算法
数据库·算法
m0_4939345319 小时前
Redis怎样合并多天访客数据_通过PFMERGE指令聚合HyperLogLog记录
jvm·数据库·python
tjc1990100519 小时前
bootstrap怎么实现响应式的文章瀑布流布局
jvm·数据库·python
旺王雪饼 www19 小时前
MySQL常用查询语句
数据库·sql
qq_1898070319 小时前
SQL嵌套查询与物化视图_提升读性能的组合策略
jvm·数据库·python
2401_8323655219 小时前
如何用消息广播机制让 Shared Worker 通知所有连接的页面
jvm·数据库·python
u01091476019 小时前
如何用 bubbles 参数让自定义事件支持在 DOM 树中冒泡
jvm·数据库·python
克里斯蒂亚诺更新19 小时前
mysql添加一个用户
数据库·mysql
Greyson119 小时前
如何解决变异表报错_ORA-04091复合触发器COMPOUND应用
jvm·数据库·python