pyspider +elasticsearch ,启动时报错

发布于 2022-09-03 12:16:41 字数 2015 浏览 18 评论 0

如题,我用最新的pyspider版本,连接远程的elasticsearch ,会说host无法识别

 File "D:\Anaconda2\lib\site-packages\pyspider\run.py", line 43, in <lambda>
    return utils.Get(lambda: connect_database(value))
  File "D:\Anaconda2\lib\site-packages\pyspider\database\__init__.py", line 44, in connect_database
    db = _connect_database(url)
  File "D:\Anaconda2\lib\site-packages\pyspider\database\__init__.py", line 170, in _connect_database
    return TaskDB([parsed.netloc], index=index)
  File "D:\Anaconda2\lib\site-packages\pyspider\database\elasticsearch\taskdb.py", line 23, in __init__
    self.es = Elasticsearch(hosts=hosts)
  File "D:\Anaconda2\lib\site-packages\elasticsearch\client\__init__.py", line 168, in __init__
    self.transport = transport_class(_normalize_hosts(hosts), **kwargs)
  File "D:\Anaconda2\lib\site-packages\elasticsearch\transport.py", line 112, in __init__
    self.set_connections(hosts)
  File "D:\Anaconda2\lib\site-packages\elasticsearch\transport.py", line 165, in set_connections
    connections = map(_create_connection, hosts)
  File "D:\Anaconda2\lib\site-packages\elasticsearch\transport.py", line 164, in _create_connection
    return self.connection_class(**kwargs)
  File "D:\Anaconda2\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 72, in __init__
    self.pool = pool_class(host, port=port, timeout=self.timeout, maxsize=maxsize, **kw)
  File "D:\Anaconda2\lib\site-packages\urllib3\connectionpool.py", line 173, in __init__
    ConnectionPool.__init__(self, host, port)
  File "D:\Anaconda2\lib\site-packages\urllib3\connectionpool.py", line 70, in __init__
    raise LocationValueError("No host specified.")
urllib3.exceptions.LocationValueError: No host specified.

基本的配置参数如下,其中host是远程的ip

{"taskdb": "elasticsearch+taskdb:http://host:9200/taskdb",
  "projectdb": "elasticsearch+projectdb:http://host:9200/projectdb",
  "resultdb": "elasticsearch+resultdb:http://host:9200/resultdb"
}

急求大神帮忙

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深海不蓝 2022-09-10 12:16:41

已解决问题,是config 里面的配置写的有点问题

飞烟轻若梦 2022-09-10 12:16:41

通过 Elasticsearch(['ip:port'],http_auth=(username,pwd),timeout=30) 解决,是因为密码用到了@#,希望帮到需要的人

泪冰清 2022-09-10 12:16:41

请问你的elasticsearch用的是哪个版本?
我用5.3.3在写入时报400错误。错误入下:
/usr/local/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 73, in _wrapped

    return func(*args, params=params, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/elasticsearch/client/__init__.py", line 298, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/usr/local/lib/python3.5/site-packages/elasticsearch/transport.py", line 312, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/local/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 128, in perform_request
    self._raise_error(response.status, raw_data)
  File "/usr/local/lib/python3.5/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'mapper_parsing_exception', 'failed to parse [status]')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文