I've been working on trying to integrate some form of full text search to a small assignment (for fun). Unfortunately, no matter the search term, it returns no results, not even when I enter exact information.
For example, when I perform a search using the Python console after importing the SQLAlchemy model, it returns information just as expected.
>>> Contact.query.whooshee_search('sch').all()
[<Contact u'Kimberley' u'Schuppe' u'cathie.schmitt@paucek.com'>, <Contact u'Kelsey' u'Schinner' u'walsh.ardyce@yahoo.com'>, <Contact u'Rella' u'Schamberger' u'abbott.feest@gmail.com'>]
However, when performing the same search through the Flask view from a POST parameter it returns with nothing.
@app.route('/', methods=['GET', 'POST'])
@app.route('/page/<int:page>', methods=['GET'])
def index(page=1):
if request.method == 'POST':
query = request.form['search']
result = Contact.query.whooshee_search(query).all()
print query, 'result:', result
contact = Contact.query.with_entities(Contact.lname, Contact.fname, Contact.phone, Contact.addr, Contact.email).paginate(page, app.config['PAGE_MAX'], False)
return render_template('index.html', entry=contact)
Result from search of 'sch' from form:
sch result: []
What could be causing this? I'm genuinely stumped why the same query from the console works fine, but through the view returns nothing.