Reputation: 57
I tried to use the following code to create and load data into an index using python:
from datetime import datetime
from elasticsearch import Elasticsearch
from elasticsearch import helpers
es = Elasticsearch()
actions = [
{
"_index": "tickets-index",
"_type": "tickets",
"_id": j,
"_source": {
"any":"data" + str(j),
"timestamp": datetime.now()}
}
for j in range(0, 10)
]
helpers.bulk(es, actions)
On executing the code, it shows:
elasticsearch.exceptions.TransportError: TransportError(406, u'Content-Type header [] is not supported')
I guess this code was previously written by someone on this forum as a solution, but it did not work for me. Please let me know on why do we get this issue and how can i get this solved.
Thanks in advance.
Upvotes: 1
Views: 256
Reputation: 691
Check if your are running the same version of the library and elasticsearch. Set something like elasticsearch>=6.0.0,<7.0.0 in requirements.txt, depending on you ES version.
You can get more info about requirements.txt here, and here about the versions available of the library. Use pip unistall to remove the elastic library and reinstall it in the correct version (related to your elasticsearch cluster version) with pip install -r requirements.txt
Upvotes: 1