Search Flask-SQLAlchemy Database

I am currently running the following code:

User.query.filter(or_(User.username.contains(query), User.name.contains(query)))

But, of course, when you click on several million records and look at several columns, LIKE "%query%" starts to go up. Whoosh very deprecated, and sqlalchemy-fulltext-search does not seem to want to work with my Flask structures. Do I have any options to consider other than switching to PostgreSQL ?

+5
source share
1 answer

Flask_sqlalchemy - your ORM is not your DBMS. You can use it with PostgreSQL as your database.
How do you query your database, which is important in your case.

1-core sqlalchemy

SQLAlchemy allows you to execute raw SQL commands, so you can write your own query commands yourself, rather than using Model.query.filter() .
Thus, one of the options is to write your select expressions yourself and more efficiently.

2-ELK

elastic search contains many effective algorithms for you! you can rely on elasticsearch to search your database.

0
source

Source: https://habr.com/ru/post/1244245/


All Articles