def test_facets(database): docs = Document.search('') facets = Document.facets(docs) assert 'x' in facets assert 'y' in facets docs = Document.search('', filters=[('x', '3')]) facets = Document.facets(docs, ignores=['x']) assert not facets docs = Document.search('', filters=[('x', '1')]) facets = Document.facets(docs, ignores=['x']) assert 'y' in facets
def search(path=None): query = request.args.get('query', '') filters = [item.split('=', 1) for item in path.split('/')] \ if path else [] ignores = [item[0] for item in filters] hits = Document.search(query, filters) facets = Document.facets(hits, ignores=ignores) return render_template('search.j2', query=query, path=path, hits=hits, facets=facets, total=Document.count())