2

Tutorial at http://pythonhosted.org/Flask-WhooshAlchemy/ works for me.

Here's my setup

class Post(db.Model):
    __tablename__ = 'post'
    __searchable__ = ['body']

    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String)

Results:

If I do not put whoosh_index() before whoosh_search(), I get the error: AttributeError: 'BaseQuery' object has no attribute 'whoosh_search'

db.session.query(Post).filter(Post.body=='hi') returns the correct output. Post.query.whooshee_search('hi') returns empty

I did leave some code out, like additional columns and backrefs, but I don't think that changes anything

There are a few things to note:

  • Tutorial worked fine without whoosh_index(), but my code threw error when I did not include it.
  • db.session.query(Post).filter() code worked fine, indicating my model is at least somewhat correct, and there is something wrong with whoosh/my whoosh setup

Please help, thanks

onepiece
  • 3,279
  • 8
  • 44
  • 63

1 Answers1

0

I too was facing the same issue as Post.query.whoosh_search('post').all() returned empty list all the time.

I found that it can be solved with using the specific versions specified here https://github.com/gyllstromk/Flask-WhooshAlchemy/blob/master/requirements.txt

I was using following versions:

Flask==0.10.1

Flask-SQLAlchemy-2.1

Whoosh-2.7.2

blinker-1.4

I replaced them with:

**Flask==0.10.1**

**Flask-SQLAlchemy==1.0**

**Whoosh==2.6.0**

**blinker==1.3**

I will update here once I find exactly which upgrade causes this problem and why.

Thomas Bormans
  • 5,156
  • 6
  • 34
  • 51