I am using Flask
(python
), creating whooshe
search, I have followed all steps from this link, also tried from other links too, but every time at end I came to this error:
results = BlogPost.query.whoosh_search('cool')
AttributeError:'BaseQuery' object has no attribute 'whoosh_search'
Here is my model code:
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)
I am having error on this:
@app.route('/search')
def search():
results = BlogPost.query.whoosh_search('cool')
return results