While executing a search on preloaded data in elasticsearch, the error occurs

GET /sample/_search [status:406 request:0.001s]

TransportError Traceback (most recent call last)
in
----> 1 search_results = search_now(text)
2 synonyms =
3 def check(search_results):
4 for text in search_results['hits']['hits']:
5 synonyms.append(text["_source"]["title"])

in search_now(text)
4
5 def search_now(text):
----> 6 res = es.search(index=db,body=search)
7 return (res)
8 def syn_search(text):

/anaconda3/lib/python3.7/site-packages/elasticsearch/client/utils.py in _wrapped(*args, **kwargs)
66 for p in es_query_params + GLOBAL_PARAMS:
67 if p in kwargs:
---> 68 v = kwargs.pop(p)
69 if v is not None:
70 params[p] = _escape(v)

/anaconda3/lib/python3.7/site-packages/elasticsearch/client/init.py in search(self, index, doc_type, body, params)
495 list of fields to return
496 :arg _source_exclude: A list of fields to exclude from the returned
--> 497 _source field
498 :arg _source_include: A list of fields to extract and return from the
499 _source field

/anaconda3/lib/python3.7/site-packages/elasticsearch/transport.py in perform_request(self, method, url, params, body)
305 timeout = params.pop('request_timeout', None)
306 ignore = params.pop('ignore', ())
--> 307 if isinstance(ignore, int):
308 ignore = (ignore, )
309

/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py in perform_request(self, method, url, params, body, timeout, ignore)
84 raise ImproperlyConfigured("When using ssl_context, use_ssl, verify_certs, ca_certs and ssl_version are not permitted")
85
---> 86 # if ssl_context provided use SSL by default
87 if use_ssl or ssl_context:
88 if not ca_certs and not ssl_context and verify_certs:

/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/base.py in _raise_error(self, status_code, raw_data)
100 # body has already been serialized to utf-8, deserialize it for logging
101 # TODO: find a better way to avoid (de)encoding the body back and forth
--> 102 if body:
103 body = body.decode('utf-8', 'ignore')
104

TransportError: TransportError(406, 'Content-Type header is not supported')

Please help

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.