我一直在学习有关开发个性化语音助手的简单教程。为此,我正在使用 Elasticsearch。当我尝试运行代码时,我收到了来自 elasticsearch 的错误提示Failed to establish new connection
。我不确定是什么导致了这个错误,因为我已经安装了 elasticsearch 和它的 python 客户端。
我已经检查过我是否已经安装了弹性搜索和它的 python 客户端,我已经完成了。我已经通过pip3安装安装了python客户端。我还检查了连接 URL 是否正确,我相信它是正确的,即https://localhost:9200/
.
我正在使用 macOS。
s = Elasticsearch(['https://localhost:9200/'])
bulk(es, records, index='voice_assistant', doc_type='text', raise_on_error=True)
def search_es(query):
res = es.search(index="voice_assistant", doc_type="text", body={
"query" :{
"match": {
"voice_command": {
"query": query,
"fuzziness": 2
}
}
},
})
return res['hits']['hits'][0]['_source']['sys_command'
实际的错误信息是
File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 105, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.VerifiedHTTPSConnection object at 0x1266dce10>: Failed to establish a new connection: [Errno 61] Connection refused)
任何人都可以帮我解决这个错误。我第一次使用elasticsearch。
编辑:我尝试在终端中运行 elasticsearch 并且收到以下警告,
OpenJDK 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
我在谷歌上进一步搜索了这个警告,并找到了一个答案,提到它可能在弹性搜索中可能是错误的,我不确定,因为我使用的是最新版本。我提到的答案是
https://stackoverflow.com/questions/48696080/java-hotspottm-64-bit-server-vm-warning-cannot-open-file-logs-gc-log-due-to-no
Edit2:现在当我尝试在 erminal 中启动 elasticsearch 时,我收到以下错误
StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.0.jar:7.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.0.jar:7.4.0]
我昨天也遇到了同样的错误,但是当我重新启动系统时,一切正常,是不是因为某种操作正在运行,并且它是否有任何特定killall
命令在启动之前终止所有操作?
通过使用最新版本的 python-es 模块,问题得到了解决,因此最好升级模块。在上述情况下,以前使用的版本是 2.4.0v,现在使用的最新版本是 6.0.0v,因此问题得到解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句