Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django/Haystack error: elasticsearch.exceptions.RequestError: TransportError(400, 'parsing_exception',...)

I am using elasticsearch as backend for haystack in my Django project. I created everything required for a search as mentioned here. But when i search i throws a traceback error with TransportError(400, 'parsing_exception', 'no [query] registered for [filtered]').

I have googled for this issue. But don't get any solution. I would appreciate helping me solve this.

My traceback:

Traceback (most recent call last):
  File "c:\python34\lib\site- packages\haystack\backends\elasticsearch_backend.py", line 524, in search
_source=True)
  File "c:\python34\lib\site-packages\elasticsearch\client\utils.py", line 71, in _wrapped
    return func(*args, params=params, **kwargs)
  File "c:\python34\lib\site-packages\elasticsearch\client\__init__.py", line 569, in search
    doc_type, '_search'), params=params, body=body)
 File "c:\python34\lib\site-packages\elasticsearch\transport.py", line 327, in perform_request
   status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "c:\python34\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 124, in perform_request
    self._raise_error(response.status, raw_data)
  File "c:\python34\lib\site-packages\elasticsearch\connection\base.py", line 122, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400,  'parsing_exception', 'no [query] registered for [filtered]')
[28/Dec/2016 17:06:58]"GET /search/?q=code HTTP/1.1" 200 395

Update-1 : TraceBack after downgraded to elasticsearch==1.7.0

GET /haystack/modelresult/_search?_source=true [status:400 request:0.001s]
Failed to query Elasticsearch using '(code)': TransportError(400, 'parsing_exception')
Traceback (most recent call last):
  File "c:\python34\lib\site-packages\haystack\backends\elasticsearch_backend.py", line 524, in search
_source=True)
  File "c:\python34\lib\site-packages\elasticsearch\client\utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "c:\python34\lib\site-packages\elasticsearch\client\__init__.py", line 527, in search
    doc_type, '_search'), params=params, body=body)
  File "c:\python34\lib\site-packages\elasticsearch\transport.py", line 307, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "c:\python34\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 93, in perform_request
    self._raise_error(response.status, raw_data)
  File "c:\python34\lib\site-packages\elasticsearch\connection\base.py", line 105, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'parsing_exception')
[28/Dec/2016 17:58:50]"GET /search/?q=code HTTP/1.1" 200 395
like image 896
sumanth Avatar asked Dec 28 '16 11:12

sumanth


1 Answers

no [query] registered for [filtered]

From what I can see you are running ES 5.0 and you're sending a filtered query which has been deprecated in ES 2.x and removed in ES 5.x.

You need to replace it with a bool/filter query instead.

So if you had something like this:

{
  "query": {
    "filtered": {
      "filter": {}
    }
  }
}

Simply replace it with

{
  "query": {
    "bool": {
      "filter": {}
    }
  }
}
like image 143
Val Avatar answered Sep 30 '22 12:09

Val