elasticsearch 无法访问该页面

but5z9lq  于 2023-01-20  发布在  ElasticSearch
关注(0)|答案(2)|浏览(297)

我是ElasticSearch和Haystack的新手,按照Tutorial: Utilizing Existing FAQs for Question Answering使用代码初始化DocumentStore:

import os
import time

from haystack.document_stores import ElasticsearchDocumentStore

# Wait 30 seconds only to be sure Elasticsearch is ready before continuing
time.sleep(30)

# Get the host where Elasticsearch is running, default to localhost
host = os.environ.get("ELASTICSEARCH_HOST", "localhost")

document_store = ElasticsearchDocumentStore(
    host=host,
    username="",
    password="",
    index="document",
    embedding_field="question_emb",
    embedding_dim=384,
    excluded_meta_data=["question_emb"],
    similarity="cosine",
)

还尝试了简单版本,如:

from haystack.document_stores import ElasticsearchDocumentStore
doc_store = ElasticsearchDocumentStore(
    scheme="https",
    host='localhost',
    username='', password='',
    index='test' 
)

但都失败了错误:

WARNING:elasticsearch:GET https://localhost:9200/ [status:N/A request:0.037s]
Traceback (most recent call last):
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connection.py", line 362, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 386, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dell\anaconda3\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 255, in perform_request
    response = self.pool.urlopen(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\util\retry.py", line 386, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\connection.py", line 362, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\dell\anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 386, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\dell\anaconda3\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)
---------------------------------------------------------------------------
ConnectionError                           Traceback (most recent call last)
~\anaconda3\lib\site-packages\haystack\document_stores\elasticsearch.py in _init_elastic_client(cls, host, port, username, password, api_key_id, api_key, aws4auth, scheme, ca_certs, verify_certs, timeout, use_system_proxy)
    270                 if not status:
--> 271                     raise ConnectionError(
    272                         f"Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance "

ConnectionError: Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `[{'host': 'localhost', 'port': 9200}]` and that it has finished the initial ramp up (can take > 30s).

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-30-40f9994332f1> in <module>
----> 1 doc_store = ElasticsearchDocumentStore(
      2     scheme="https",
      3     host='localhost',
      4     username='elastic', password='do4-uzbyc4ZN2yUKBhtJ',
      5     index='CS1302'

~\anaconda3\lib\site-packages\haystack\nodes\base.py in wrapper_exportable_to_yaml(self, *args, **kwargs)
     46 
     47         # Call the actuall __init__ function with all the arguments
---> 48         init_func(self, *args, **kwargs)
     49 
     50     return wrapper_exportable_to_yaml

~\anaconda3\lib\site-packages\haystack\document_stores\elasticsearch.py in __init__(self, host, port, username, password, api_key_id, api_key, aws4auth, index, label_index, search_fields, content_field, name_field, embedding_field, embedding_dim, custom_mapping, excluded_meta_data, analyzer, scheme, ca_certs, verify_certs, recreate_index, create_index, refresh_type, similarity, timeout, return_embedding, duplicate_documents, index_type, scroll, skip_missing_embeddings, synonyms, synonym_type, use_system_proxy)
    141 
    142         # Base constructor might need the client to be ready, create it first
--> 143         client = self._init_elastic_client(
    144             host=host,
    145             port=port,

~\anaconda3\lib\site-packages\haystack\document_stores\elasticsearch.py in _init_elastic_client(cls, host, port, username, password, api_key_id, api_key, aws4auth, scheme, ca_certs, verify_certs, timeout, use_system_proxy)
    274                     )
    275         except Exception:
--> 276             raise ConnectionError(
    277                 f"Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `{hosts}` and that it has finished the initial ramp up (can take > 30s)."
    278             )

ConnectionError: Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `[{'host': 'localhost', 'port': 9200}]` and that it has finished the initial ramp up (can take > 30s).

我用的是windows10,elasticsearch版本是8.6(最新版),我不用docker。任何帮助都很感激!(附言:我看过Haystack's ElasticsearchDocumentStore() cannot connect running ElasticSearch container的帖子,但仍然不知道该怎么做。)

bxjv4tth

bxjv4tth1#

到目前为止(2023年1月),Haystack还不支持elasticsearch版本8。我建议你使用版本7。你可以关注下面的GitHub问题,那里跟踪了版本8的支持情况:https://github.com/deepset-ai/haystack/issues/2810

dsekswqp

dsekswqp2#

我还没有找到一个直接解决原来的问题,但我试图使用docker和一切顺利的ElasticSearch版本是7.9.2。希望能帮助别人有同样的问题。

相关问题