1

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

how do we get this requirements.txt? can you please elaborate on this??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.