Elasticsearch 查询超出10000条时

1、参考https://blog.csdn.net/Misaki_root/article/details/101203647

es本身默认限制了查找的量为10000条,即 from+size<=10000

解决方法: 

1、 在config/elasticsearch.yml中添加配置 (但这种方法在7.3.2报错)

max_result_window: 1000000000
2、 使用api修改index的配置

# 修改es中所有的index配置
 

curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/_settings -d '{ "index" : { "max_result_window" : 1000000000}}'

2、此时hits.total.value还是为10000,

解决方法:查询语句中加入:  "track_total_hits": true

比如这样:

        "track_total_hits": true,
    "query":{"bool":{"filter": [] } } ,
    "from": 0,
    "size": 30,
    "sort": { "time": { "order": "desc" } }
}

 

参考 https://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-request-track-total-hits.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值