I found the search query a little bit complicated, in the sense it can be difficult to adjust it to the user's input.
For example, how do I permit the user to enter the parameters in different order without "hardcoding" the position of the parameters. Something like this:
q = request.args.get("q") + "%"
q = q.split(",")
if len(q) == 1:
# Make a query on db with "q" and save it to "results"
results = db.execute("SELECT * FROM places WHERE postal_code LIKE :q0 OR place_name LIKE :q0 OR admin_name1 LIKE :q0", q0=q[0])
elif len(q) == 2:
results = db.execute("SELECT * FROM places WHERE place_name LIKE :q0 AND admin_name1 LIKE :q1", q0=q[0], q1=q[1])
elif len(q) == 3:
results = db.execute("SELECT * FROM places WHERE place_name LIKE :q0 OR admin_name1 LIKE :q1 OR place_name LIKE :q2", q0=q[0], q1=q[1], q2=q[2])
I was reading the FTS way that you reccomend, but I don't know if I'm complicating too much the solution with a normal query.
PD: I understand that the user will not send a query like
http://mashup.cs50.net/search?q=massa
but I'm testing the app and I don't think my solution will adapt the user's input in an efficient way.
Thanks!