'SuggestResponse' object has no attribute 'my_suggest'

来源:15-4 django实现elasticsearch的搜索建议 - 2

慕仰7968168

2020-04-06

老师我这里搜索建议报错了,可以帮我看看嘛
[06/Apr/2020 08:09:15] “GET / HTTP/1.1” 200 5517
Internal Server Error: /suggest/
Traceback (most recent call last):
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/elasticsearch_dsl/utils.py”, line 112, in getattr
return self.getitem(attr_name)
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/elasticsearch_dsl/utils.py”, line 125, 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 “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/django/core/handlers/exception.py”, line 34, in inner
response = get_response(request)
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/django/core/handlers/base.py”, line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/django/core/handlers/base.py”, line 113, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/django/views/generic/base.py”, line 71, in view
return self.dispatch(request, *args, **kwargs)
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/django/views/generic/base.py”, line 97, in dispatch
return handler(request, *args, **kwargs)
File “/Users/undefeated/PycharmProjects/LcvSearch/search/views.py”, line 24, in get
for match in suggestions.my_suggest[0].options:
File “/Users/undefeated/Library/Python/3.7/lib/python/site-packages/elasticsearch_dsl/utils.py”, line 115, in getattr
’%r object has no attribute %r’ % (self.class.name, attr_name))
AttributeError: ‘SuggestResponse’ object has no attribute ‘my_suggest’
[06/Apr/2020 08:09:21] "GET /suggest/?s=j&s_type=undefined&
=1586160561100 HTTP/1.1" 500 15026

写回答

1回答

bobby

2020-04-07

//img.mukewang.com/szimg/5e8c3fe90981438f10470451.jpg 你看看你这个地方的逻辑是否和我的一样

0
0

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

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

5797 学习 · 6290 问题

查看课程