我在我的Django项目中使用elasticsearch作为haystack的后端。我按照here创建了搜索所需的所有内容。但是当我搜索时,我发送了一个带有TransportError的追踪错误(400,' parsing_exception','没有[查询]注册[过滤]')。
我已经用Google搜索了这个问题。但是没有得到任何解决方案。我很乐意帮助我解决这个问题。
我的追溯:
//Reload Question List when User enter the Game view.
questionService.initialize().done(function(){
//Now we got question, initialize the Game View
questionService.getQuestion().done(
function (data) {
console.log(data);
slider.slidePage(new GameView(data).render().$el);
})
});
Update-1:TraceBack降级为elasticsearch == 1.7.0
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
答案 0 :(得分:4)
没有[查询]注册[过滤]
从我可以看到您运行的是ES 5.0,您发送的filtered
查询已在ES 2.x和removed in ES 5.x中弃用。
您需要将其替换为bool/filter
query。
所以如果你有这样的事情:
{
"query": {
"filtered": {
"filter": {}
}
}
}
只需用
替换它{
"query": {
"bool": {
"filter": {}
}
}
}
答案 1 :(得分:0)
Elasticsearch已弃用filtered
查询。请改用bool
。
它对我有用。
答案 2 :(得分:0)
根据haystack docs要解决此错误,您应该在设置中设置正确的haystack引擎后端版本。 对于Elasticsearch v 5.x.x,它将是
H_ENGINE = 'haystack.backends.elasticsearch5_backend.Elasticsearch5SearchEngine'