Fix search with SQLAlchemy