Я допустил ошибки, когда использовал Python для вставки простых данных вasticsearch - PullRequest
0 голосов
/ 05 сентября 2018

Я только что коснулся упругого поиска, и после нескольких простых уроков по python произошла ошибка при вставке данных. Моя упругая поисковая версия была 6.4.0, а моя версия Python была 3.6, версия macOS была 10.13.6 код:

#from datetime import datetime
from elasticsearch import Elasticsearch

es = Elasticsearch()

es.indices.create(index='my-index', ignore=400)

es.index(index="my-index", doc_type="test-type", id=1, body={"any":"data01", "timestamp": datetime.now()})

Ошибка:

PUT /my-index/test-type/1 [status:406 request:0.002s]
Traceback (most recent call last):
  File "/Users/kenneth/PycharmProjects/Python核心编程/Elasticsearch/Python对接Elasticsearch/demo.py", line 8, in <module>
    es.index(index="my-index", doc_type="test-type", id=1, body={"any":"data01", "timestamp": datetime.now()})
  File "/Users/kenneth/Library/Python/3.6/lib/python/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/kenneth/Library/Python/3.6/lib/python/site-packages/elasticsearch/client/__init__.py", line 263, in index
    _make_path(index, doc_type, id), params=params, body=body)
  File "/Users/kenneth/Library/Python/3.6/lib/python/site-packages/elasticsearch/transport.py", line 307, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Users/kenneth/Library/Python/3.6/lib/python/site-packages/elasticsearch/connection/http_urllib3.py", line 93, in perform_request
    self._raise_error(response.status, raw_data)
  File "/Users/kenneth/Library/Python/3.6/lib/python/site-packages/elasticsearch/connection/base.py", line 105, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: TransportError(406, 'Content-Type header [] is not supported')
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...