'Response' object has no attribute 'my_suggest'就是不能推荐

来源:14-1 elasticsearch介绍

慕斯卡9173574

2019-02-16

[16/Feb/2019 17:41:14] “GET / HTTP/1.1” 200 5973
Internal Server Error: /suggest/
Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 127, in getattr
return self.getitem(attr_name)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\response_init_.py”, line 18, in getitem
return super(Response, self).getitem(key)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 140, in getitem
return _wrap(self.d[key])
KeyError: ‘my_suggest’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py”, line 35, in inner
response = get_response(request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 128, in get_response
response = self.process_exception_by_middleware(e, request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 126, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 69, in view
return self.dispatch(request, *args, **kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 89, in dispatch
return handler(request, *args, **kwargs)
File “E:\LcvSearch\search\views.py”, line 34, in get
for match in suggestions.my_suggest[0].options:
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 130, in getattr
’%r object has no attribute %r’ % (self.class.name, attr_name))
AttributeError: ‘Response’ object has no attribute ‘my_suggest’
[16/Feb/2019 17:41:24] "GET /suggest/?s=g&s_type=article&
=1550310084447 HTTP/1.1" 500 17165
Internal Server Error: /suggest/
Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 127, in getattr
return self.getitem(attr_name)
File "D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\response_init
.py", line 18, in getitem
return super(Response, self).getitem(key)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 140, in getitem
return _wrap(self.d[key])
KeyError: ‘my_suggest’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py”, line 35, in inner
response = get_response(request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 128, in get_response
response = self.process_exception_by_middleware(e, request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 126, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 69, in view
return self.dispatch(request, *args, **kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 89, in dispatch
return handler(request, *args, **kwargs)
File “E:\LcvSearch\search\views.py”, line 34, in get
for match in suggestions.my_suggest[0].options:
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 130, in getattr
’%r object has no attribute %r’ % (self.class.name, attr_name))
AttributeError: ‘Response’ object has no attribute ‘my_suggest’
[16/Feb/2019 17:41:24] "GET /suggest/?s=gi&s_type=article&
=1550310084508 HTTP/1.1" 500 17168
Internal Server Error: /suggest/
Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 127, in getattr
return self.getitem(attr_name)
File "D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\response_init
.py", line 18, in getitem
return super(Response, self).getitem(key)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 140, in getitem
return _wrap(self.d[key])
KeyError: ‘my_suggest’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py”, line 35, in inner
response = get_response(request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py”, line 126, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 69, in view
return self.dispatch(request, *args, **kwargs)
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\generic\base.py”, line 89, in dispatch
return handler(request, *args, **kwargs)
File “E:\LcvSearch\search\views.py”, line 34, in get
for match in suggestions.my_suggest[0].options:
File “D:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\elasticsearch_dsl\utils.py”, line 130, in getattr
’%r object has no attribute %r’ % (self.class.name, attr_name))
AttributeError: ‘Response’ object has no attribute ‘my_suggest’
[16/Feb/2019 17:41:25] "GET /suggest/?s=git&s_type=article&
=1550310085558 HTTP/1.1" 500 17171

写回答

1回答

bobby

2019-02-19

https://git.imooc.com/coding-92/coding-92/src/master/LcvSearch/search/views.py 你看看这里的代码 看看是不是有不一致的地方 可以拷贝过去 //img.mukewang.com/szimg/5c6bb5000001d8bc07880391.jpg

0
5
bobby
回复
慕斯卡9173574
已经通过了
2019-02-23
共5条回复

Scrapy打造搜索引擎 畅销4年的Python分布式爬虫课

带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎

5796 学习 · 6290 问题

查看课程