oliver006 / elasticsearch-gmail

Index your Gmail Inbox with Elasticsearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tornado.httpcient.HTTPError: 406 Not acceptable

NicolaeCasir opened this issue · comments

Hi. I have a problem. I get this error:

python index_emails.py --infile=email.mbox [I 180429 15:01:57 index_emails:170] Starting import from file email.mbox Traceback (most recent call last): File "index_emails.py", line 222, in <module> IOLoop.instance().run_sync(load_from_file) File "/Library/Python/2.7/site-packages/tornado/ioloop.py", line 458, in run_sync return future_cell[0].result() File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 238, in result raise_exc_info(self._exc_info) File "/Library/Python/2.7/site-packages/tornado/ioloop.py", line 436, in run result = func() File "index_emails.py", line 188, in load_from_file upload_batch(upload_data) File "index_emails.py", line 92, in upload_batch response = http_client.fetch(request) File "/Library/Python/2.7/site-packages/tornado/httpclient.py", line 102, in fetch self._async_client.fetch, request, **kwargs)) File "/Library/Python/2.7/site-packages/tornado/ioloop.py", line 458, in run_sync return future_cell[0].result() File "/Library/Python/2.7/site-packages/tornado/concurrent.py", line 238, in result raise_exc_info(self._exc_info) File "<string>", line 3, in raise_exc_info tornado.httpclient.HTTPError: HTTP 406: Not Acceptable

What . can i do?

[UPDATE]
I tried to see what i wrong... and.. when it want to create index it gets:
[I 180429 15:08:35 index_emails:81] HTTP 400: Bad Request

Not sure what's going wrong - does your Elasticsearch node have any more information why the request fails?

[SOLVED]
Problem was in syntax, because i Use ES6 and in headers..
My code for create index:
Schema:
schema = { "settings": { "number_of_shards": tornado.options.options.num_of_shards, "number_of_replicas": 0 }, "mappings": { "email": { "_source": {"enabled": True}, "properties": { "from": {"type": "text", "index": True}, "return-path": {"type": "text", "index": True}, "delivered-to": {"type": "text", "index": True}, "message-id": {"type": "text", "index": True}, "to": {"type": "text", "index": True}, "date_ts": {"type": "date"} } } }, "refresh": True }

and request:
try: headers = {"Content-type": 'application/json'} request = HTTPRequest(url, method="PUT", body=body, request_timeout=240, headers=headers) response = http_client.fetch(request) logging.info('Create index done %s' % response.body) except: pass

P.S. Star from me... Good JOB!