I have a query that I know works:
SELECT title FROM paper WHERE MATCH (title) AGAINST ('+exact +representations' IN BOOLEAN MODE)
This returns any papers with both the words "exact" and "representations". Using SQLAlchemy's string replacement, I do:
keyword = '+exact +representations'
sql = 'SELECT title FROM paper WHERE MATCH (title) AGAINST (:keyword IN BOOLEAN MODE)'
conn = db.engine.connect()
t = conn.execute(text(sql), keyword=keyword)
This fails to match just papers with both keywords. Instead, it returns papers with either word.
My guess is that SQLAlchemy is mangling keyword
in its preprocessing step. How can I use SQLAlchemy's string replacement feature but still do what I want?