问题
I need to increase the max_result_window in elasticsearch using a python. Here is my code:
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
)
However, suddenly my elasticsearch stopped, and I got an error as below when I run the code:
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)
Another code as below I got from cmd elasticsearch before it stop:
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]
Can anyone help me to solve this issue?
回答1:
Based upon the exception from Elasticsearch, it looks like Elastic simply ran out of available memory, reaching "OOM error" state
Assuming your system has enough memory, you may be able to fix this by assigning a larger heap, which appears to be 1G by default:
https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch
If this still doesn't work, you will likely need to settle for a smaller result window and further paginate the results yourself:
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
来源:https://stackoverflow.com/questions/63996699/error-when-increase-the-max-result-window-in-elasticsearch-using-a-python