Elasticsearch 7.11使用PIT分页查询时提示[indices] cannot be used with point in time的解决方法
解决Elasticsearch PIT分页时"indices cannot be used with point in time"错误
你遇到的这个错误原因非常清晰:当使用Point in Time(PIT)进行搜索时,不能同时指定index参数。因为你创建PIT的时候已经关联了目标索引(或索引集合),PIT ID本身就包含了索引的上下文信息,后续查询时再指定index会触发参数冲突的验证错误。
修改后的查询调用代码
只需要去掉search方法中的index="data_store"参数即可:
result = elastic_connector.search(body=search_param, ignore=[400, 404]) print('result' , result)
补充说明
- PIT的索引绑定逻辑:创建PIT时你肯定已经指定了要关联的索引(比如
data_store),这个信息会被编码到返回的PIT ID中,后续使用该ID查询时,Elasticsearch会自动关联对应的索引,无需重复指定。 - 关于你提到的GitHub问题:你看到的那个问题确实和当前场景匹配,核心就是PIT与
index参数互斥的设计限制,在Elasticsearch 7.11版本中这个限制是生效的。 - 资源注意事项:记得在分页完成后,调用
delete_point_in_time接口关闭PIT,避免占用集群资源,示例代码如下:
elastic_connector.delete_point_in_time(body={"pit_id": "你的PIT ID"})
内容的提问来源于stack exchange,提问作者blue-sky
相关产品推荐
相关产品推荐

