Custom Functions in Flask-SQLAlchemy with PostgreSQL

Posted on Posted in Articles

I have a Flask-SQLAlchemy model backed by a PostgreSQL database that looks like this: class Thing(db.Model) title = db.Column(db.Text(), nullable=False) narrative = db.Column(db.Text(), nullable=False) tags = db.Column(ARRAY(db.Text()), index=True) My customer wants to have a full text search over all three fields simultaneously, but wants the results ordered by where the hits are. They should be ordered […]