使用python在elasticsearch中增加“最大结果”窗口时出错

2024-10-02 02:34:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要使用python增加elasticsearch中的max_result_窗口。这是我的密码:

elastic_client = Elasticsearch([{'host': 'localhost', 'port': 9200}], timeout=800)

elastic_client.indices.put_settings(index="studentvle",body= {"index" : {"max_result_window" : 8609436}})

total_docsstudentvle = 8609436
responsestudentvle = elastic_client.search(
    index='studentvle',
    body={},
    size=total_docsstudentvle
)

然而,我的elasticsearch突然停止,当我运行代码时,我得到了如下错误:

ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x005DF1A8>: Failed to
establish a new connection: [WinError 10061] No connection could be made because the target machine
actively refused it) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at
0x005DF1A8>: Failed to establish a new connection: [WinError 10061] No connection could be made because
the target machine actively refused it)

在cmd elasticsearch停止之前,我从cmd elasticsearch获得了另一个代码,如下所示:

java.lang.OutOfMemoryError: Java heap space
Dumping heap to data\java_pid15608.hprof ...

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ticker-schedule-trigger-engine"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "elasticsearch[DESKTOP-8MLV90U][generic][T#4]"

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "elasticsearch[DESKTOP-8MLV90U][generic][T#5]"
Heap dump file created [1482063561 bytes in 345.992 secs]

有人能帮我解决这个问题吗


Tags: thetoinfromclientlangindexexception
1条回答
网友
1楼 · 发布于 2024-10-02 02:34:10

基于Elasticsearch的异常,看起来Elastic只是耗尽了可用内存,达到了"OOM error"状态

假设您的系统有足够的内存,您可以通过分配一个更大的堆(默认为1G)来解决此问题:
https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch

如果这仍然不起作用,您可能需要选择一个较小的结果窗口,并自己对结果进行进一步分页:
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after

相关问题 更多 >

    热门问题