python操作es处理超过10000条数据报错查询不到

报错信息如下

elasticsearch.exceptions.TransportError: TransportError(500, 'search_phase_execution_exception', 'Result window is too large, from + size must be less than or equal to

解决办法:

在创建索引的时候添加:

mappings = {
    "mappings": {
        "numerical_keyword": {
            "properties": {
                "search_keyword": {  # 搜索关键词
                    "type": "text",
                    "index": "true"
                }
            }
        }
    },
    "settings": {
        "index": {
            "max_result_window": 500000  # 数量限制,可以自己定义
                }
            }
}

这个办法可以完美解决

猜你喜欢

转载自www.cnblogs.com/itBlogToYpl/p/13209680.html
今日推荐