2

I have a problem setting up whoosh_search in my application.

Very fast, let me show you my files configurations.

settings.py:

basedir = os.path.abspath(os.path.dirname(__file__))
WHOOSH_BASE = os.path.join(basedir, 'search.db')

models.py:

import flask_whooshalchemy as whooshalchemy

class Post(Base):

    __tablename__ = 'post'
    __searchable__ = ['title', 'type_course']

    id = db.Column(db.Integer, primary_key=True)
    author_id = db.Column(db.Integer, db.ForeignKey('author.id'))
    title = db.Column(db.String(500))
    type_course = db.Column(db.String(20))
    about_course = db.Column(db.Text())

Inside the shell if i tried to test if it does work or not am getting this error:

>>> from pro.main.models import Post
>>> p = Post.query.whoosh_search('cool')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'BaseQuery' object has no attribute 'whoosh_search'

I have read another articles that issued this problem but am still getting the same issue.

Another thing to mention, i have this code almost in all files: sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))), maybe this cause some problems !!, am not really sure because the application worked without any errors .

Eventually, any help would be tons appreciated .

Reznov
  • 175
  • 1
  • 3
  • 14
  • I forgot to add `whoosh_index(app, Post)` to the end of the file then the error disappeared , but still have a problem, I am getting empty list no results, Why ? – Reznov Aug 25 '16 at 19:16

0 Answers0