def search(): q = request.args.get('q','') query = sp.parse_query(q) articles = data.Article.objects(**query)[:config.max_articles] return render_template("index.html", articles=articles, num_articles=articles.count(), q=q)
def test_parse_query(): qb = search_parser.query_builder() q1 = qb.tag("foo").keyword("bar").get() q2 = search_parser.parse_query("t:foo bar") assert q1==q2, "Expected: %s, got %s" % (str(v),str(q))