【发布时间】:2021-01-19 22:40:50
【问题描述】:
感谢您对此进行调查,我正在尝试了解弹性搜索的基础知识,而我正在关注 This medium tutorial,因此通过执行基本的 python 脚本它给了我以下错误
raise ConnectionError("N/A", str(e), e)
elasticsearch.exceptions.ConnectionError:
ConnectionError(<urllib3.connection.HTTPConnection object
at 0x00000209314C2D88>:
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 0x00000209314C2D88>:
Failed to establish a new connection:
[WinError 10061] No connection could be made because the target machine actively refused it)
python 脚本
from elasticsearch import Elasticsearch
es = Elasticsearch([{'host':'localhost','port':9200}])
e1={
"first_name":"nitin",
"last_name":"panwar",
"age": 27,
"about": "Love to play cricket",
"interests": ['sports','music'],
}
e2={
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests": [ "music" ]
}
e3={
"first_name" : "Douglas",
"last_name" : "Fir",
"age" : 35,
"about": "I like to build cabinets",
"interests": [ "forestry" ]
}
res = es.index(index='megacorp',doc_type='employee',id=1,body=e1)
print(res['created'])
你能帮我解决这个问题吗,我还通过 pip install
安装了 elasticsearch【问题讨论】:
-
你能显示 curl localhost:9200 的输出吗?我希望你的 ES 和代码都在同一台机器上运行?
-
@ElasticsearchNinja 这里
curl : The URI prefix is not recognized. At line:1 char:1 + curl localhost:9200 + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplemented: (: ) [Invoke-WebRequest], NotSupportedException + FullyQualifiedErrorId : WebCmdletIEDomNotS upportedException,Microsoft.PowerShell.Comma nds.InvokeWebRequestCommand -
在我的第一条评论中你到底有什么不明白的地方??
-
什么是 curl,我需要它来运行弹性搜索吗,
-
你在用windows吗?
标签: python elasticsearch