创建 AWS Elasticsearch 索引时出现 404 HEAD 问题
404 HEAD issue when creating AWS Elasticsearch index
我正在尝试使用 python 创建我的第一个索引,但我一直收到 404 索引未找到异常。这是当前代码:
es = Elasticsearch([{'host': 'host_url', 'port': 443, 'use_ssl': True, 'timeout': 300}])
if es.indices.exists('test_logs'):
es.indices.delete(index = 'test_logs')
request_body = {
'settings': {
'number_of_shards': 2,
'number_of_relicas': 2
},
'mappings': {
'logs': {
'properties': {
'date': { 'index': 'not_analyzed', 'type': 'date' },
'time': { 'index': 'not_analyzed', 'type': 'time' },
'request': { 'index': 'not_analyzed', 'type': 'string' },
'status': { 'index': 'not_analyzed', 'type': 'int' },
'agent': { 'index': 'not_analyzed', 'type': 'string' }
}
}
}
}
es.indices.create(index = 'test_logs', ignore = [400, 404], body = request_body, request_timeout = 30)
编辑:我改变了一些东西,现在我得到了一个不同的错误。我已经更新了新问题的代码和标题。这是我的输出:
C:\Python34\lib\site-packages\elasticsearch\connection\http_urllib3.py:54: UserW
arning: Connecting to host_url using SSL with verify_certs=False is insecure.
'Connecting to %s using SSL with verify_certs=False is insecure.' % host)
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
HEAD /test_logs [status:404 request:0.902s]
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Press any key to continue . . .
HEAD /test_logs 404 是什么意思?
将我的连接更改为:
es = Elasticsearch(
hosts = host,
connection_class = RequestsHttpConnection,
port = 443,
use_ssl = True,
verify_certs = False)
现在工作正常。不知道为什么上一个失败了。
我正在尝试使用 python 创建我的第一个索引,但我一直收到 404 索引未找到异常。这是当前代码:
es = Elasticsearch([{'host': 'host_url', 'port': 443, 'use_ssl': True, 'timeout': 300}])
if es.indices.exists('test_logs'):
es.indices.delete(index = 'test_logs')
request_body = {
'settings': {
'number_of_shards': 2,
'number_of_relicas': 2
},
'mappings': {
'logs': {
'properties': {
'date': { 'index': 'not_analyzed', 'type': 'date' },
'time': { 'index': 'not_analyzed', 'type': 'time' },
'request': { 'index': 'not_analyzed', 'type': 'string' },
'status': { 'index': 'not_analyzed', 'type': 'int' },
'agent': { 'index': 'not_analyzed', 'type': 'string' }
}
}
}
}
es.indices.create(index = 'test_logs', ignore = [400, 404], body = request_body, request_timeout = 30)
编辑:我改变了一些东西,现在我得到了一个不同的错误。我已经更新了新问题的代码和标题。这是我的输出:
C:\Python34\lib\site-packages\elasticsearch\connection\http_urllib3.py:54: UserW
arning: Connecting to host_url using SSL with verify_certs=False is insecure.
'Connecting to %s using SSL with verify_certs=False is insecure.' % host)
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
HEAD /test_logs [status:404 request:0.902s]
C:\Python34\lib\site-packages\urllib3\connectionpool.py:789: InsecureRequestWarn
ing: Unverified HTTPS request is being made. Adding certificate verification is
strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Press any key to continue . . .
HEAD /test_logs 404 是什么意思?
将我的连接更改为:
es = Elasticsearch(
hosts = host,
connection_class = RequestsHttpConnection,
port = 443,
use_ssl = True,
verify_certs = False)
现在工作正常。不知道为什么上一个失败了。