V
V
veitmen2015-04-03 11:06:16
PostgreSQL
veitmen, 2015-04-03 11:06:16

How to implement Full text search for Postgresql on SQLAlchemy?

Hello.

There is a Flask application. I'm using Flask-SQLAlchemy. Postgres base. There are already quite a few models of this type:

class Some(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)

    text = db.Column(db.String, nullable=False)


The task for some models is to raise Full text search. As far as I know, Postgres has FTS out of the box. All I found was SQLAlchemy-Searchable . Great thing, but requires the use of declarative models. I tried to fasten it, but, apparently, I did something wrong, because. after the start of using declarative models, alembic suggested that all tables be destroyed first, and then re-created, which does not suit me.

Tell me how to implement FTS with minimal cost? with the existing environment and restrictions?

Maybe it makes sense to move to some kind of ElasticSearch at all? Create an index for the data that I need, and work with it in parallel when adding / changing / deleting?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Abiduev, 2015-04-05
@veitmen

habrahabr.ru/post/234613 Whoosh
A long time ago I used sphinx search, updated the cache with helpers in classes, we are talking about ORM, now a decorator would do it. @update_cache or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question