http://pythonhosted.org/Flask-WhooshAlchemy/的教程为我工作。
这是我的装置
class Post(db.Model):
__tablename__ = 'post'
__searchable__ = ['body']
id = db.Column(db.Integer, primary_key=True)
body = db.Column(db.String)结果:
如果不将whoosh_index()放在whoosh_search()之前,则会得到错误:AttributeError: 'BaseQuery' object has no attribute 'whoosh_search'
db.session.query(Post).filter(Post.body=='hi')返回正确的输出。Post.query.whooshee_search('hi')返回空
我确实遗漏了一些代码,比如额外的列和回退,但我认为这不会改变任何事情。
有几件事需要注意:
whoosh_index()的情况下运行良好,但是当我不包括它时,我的代码会抛出错误。db.session.query(Post).filter()代码运行良好,表明我的模型至少是正确的,并且whoosh/my设置有问题。请帮忙,谢谢
发布于 2016-02-29 10:05:03
我也面临着同样的问题,因为Post.query.whoosh_search('post').all()一直在返回空列表。
我发现可以使用这里指定的特定版本https://github.com/gyllstromk/Flask-WhooshAlchemy/blob/master/requirements.txt来解决这个问题。
我使用了以下版本:
Flask==0.10.1
Flask-SQLAlchemy-2.1
Whoosh-2.7.2
blinker-1.4我将替换为:
**Flask==0.10.1**
**Flask-SQLAlchemy==1.0**
**Whoosh==2.6.0**
**blinker==1.3**我将在这里更新,一旦我发现究竟是哪个升级导致了这个问题,以及原因。
https://stackoverflow.com/questions/23054615
复制相似问题