csv2es icon indicating copy to clipboard operation
csv2es copied to clipboard

Header type problem

Open hbarnard opened this issue 8 years ago • 6 comments

Trying:

python csv2es.py --index-name test --doc-type test --import-file test.csv

gives:

Using host: http://127.0.0.1:9200/
Traceback (most recent call last):
  File "csv2es.py", line 215, in <module>
    cli()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "csv2es.py", line 197, in cli
    es.create_index(index_name)
  File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 92, in decorate
    return func(*args, query_params=query_params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 1005, in create_index
    query_params=query_params)
  File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 257, in send_request
    self._raise_exception(status, error_message)
  File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 271, in _raise_exception
    raise error_class(status, error_message)
pyelasticsearch.exceptions.ElasticHttpError: (406, u'Content-Type header [] is not supported')

I'm not an elasticsearch expert so, forgive me if this is something idiot.

hbarnard avatar Feb 10 '18 11:02 hbarnard

Happens to me also. i have just followed the sample code provided

jeremejazz avatar Mar 16 '18 02:03 jeremejazz

I think this is caused by the introduction of strict content-type checking by ES from version 6.0 on (see: https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests). This script seems not to pass on a content type in the header - thereby creating this issue.

daanknoope avatar Apr 16 '18 12:04 daanknoope

The same questions! hope to fix it as soon as possible!

MasonQAQ avatar Sep 06 '18 14:09 MasonQAQ

I find the way to solve the Q, just modify the requirements.txt, set the elasticsearch to your version. For example, if your version is 6.x.x you can set: elasticsearch>=6.0.0,<7.0.0

MasonQAQ avatar Sep 06 '18 15:09 MasonQAQ

I find the way to solve the Q, just modify the requirements.txt, set the elasticsearch to your version. For example, if your version is 6.x.x you can set: elasticsearch>=6.0.0,<7.0.0

Alternatively, if you are using the pip installed version, you can just upgrade elasticsearch (pip install --upgrade elasticsearch).

monktastic avatar Oct 30 '18 13:10 monktastic

Have this issue with elasticsearch-7.7.1.

danyaljj avatar Jun 09 '20 07:06 danyaljj