Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticHttpError: 406, Elastic Search Error While indexing Data

I am trying to index data in elastic search.

following is the version and other details about elastic search

{ "name" : "Tmqcj9W",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "HvwGfRrpR4-iaViCTm9ZwA",
  "version" : {
    "number" : "6.1.1",
    "build_hash" : "bd92e7f",
    "build_date" : "2017-12-17T20:23:25.338Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0",
   }"tagline" : "You Know, for Search"}

The client side code to index data is in python:

es = ElasticSearch('http://localhost:9200/')
es.create_index(index_name)
es.bulk_index("index_name", "doc_type", [{"title":"this is title","desc":"this is description"}])

I am getting the following error.

"pyelasticsearch.exceptions.ElasticHttpError: (406, 'Content-Type header [] is not supported')"

After few searches I got few suggestions saying I need to set the content type to "application/json", but I am not sure how to set this. Can anyone help me with this ?.

like image 267
Hegde Avatar asked Sep 20 '25 08:09

Hegde


1 Answers

Issue was with elasticsearch python library. I downgraded the version to 6. sudo pip3 install elasticsearch==6.0.0

like image 175
Hegde Avatar answered Sep 21 '25 20:09

Hegde