gpt4 book ai didi

python - 属性错误: 'BaseQuery' object has no attribute 'whoosh_search'

转载 作者:行者123 更新时间:2023-12-01 02:35:37 25 4
gpt4 key购买 nike

我正在使用 Flask (python),创建 whooshe 搜索,我已遵循此 link 中的所有步骤,也从其他链接尝试过,但每次最后我都会遇到这个错误:

results = BlogPost.query.whoosh_search('cool')
AttributeError:'BaseQuery' object has no attribute 'whoosh_search'

这是我的模型代码:

class BlogPost(db.Model):
__tablename__ = 'blogpost'
__searchable__ = ['title', 'content']
__analyzer__ = StemmingAnalyzer()
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.Unicode) # Indexed fields are either String,
content = db.Column(db.Text) # Unicode, or Text
created = db.Column(db.DateTime, default=datetime.utcnow)

我在这方面遇到错误:

@app.route('/search')
def search():
results = BlogPost.query.whoosh_search('cool')
return results

最佳答案

我也看到了这个错误。然后我发现错误在 models.py 中。您应该在模型代码末尾添加 whooshalchemy.whoosh_index(app, BlogPost)

关于python - 属性错误: 'BaseQuery' object has no attribute 'whoosh_search' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46272235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com